<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">--</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- Copyright (c) 2018 Andreas Klebinger</span><span>
</span><span id="line-3"></span><span class="hs-comment">--</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies, ScopedTypeVariables #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE TupleSections #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE GeneralizedNewtypeDeriving #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE Rank2Types #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# LANGUAGE DataKinds #-}</span><span>
</span><span id="line-12"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts           #-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.CmmToAsm.CFG</span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier">CFG</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier">CfgEdge</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier">EdgeInfo</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier">EdgeWeight</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TransitionSource"><span class="hs-identifier">TransitionSource</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-comment">--Modify the CFG</span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addWeightEdge"><span class="hs-identifier">addWeightEdge</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier">addEdge</span></a></span><span>
</span><span id="line-20"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#delEdge"><span class="hs-identifier">delEdge</span></a></span><span>
</span><span id="line-21"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addNodesBetween"><span class="hs-identifier">addNodesBetween</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#shortcutWeightMap"><span class="hs-identifier">shortcutWeightMap</span></a></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#reverseEdges"><span class="hs-identifier">reverseEdges</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#filterEdges"><span class="hs-identifier">filterEdges</span></a></span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addImmediateSuccessor"><span class="hs-identifier">addImmediateSuccessor</span></a></span><span>
</span><span id="line-24"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkWeightInfo"><span class="hs-identifier">mkWeightInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#adjustEdgeWeight"><span class="hs-identifier">adjustEdgeWeight</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier">setEdgeWeight</span></a></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-comment">--Query the CFG</span><span>
</span><span id="line-27"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier">infoEdgeList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#edgeList"><span class="hs-identifier">edgeList</span></a></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier">getSuccessorEdges</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier">getSuccessors</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccEdgesSorted"><span class="hs-identifier">getSuccEdgesSorted</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier">getEdgeInfo</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier">getCfgNodes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#hasNode"><span class="hs-identifier">hasNode</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-comment">-- Loop Information</span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopMembers"><span class="hs-identifier">loopMembers</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopLevels"><span class="hs-identifier">loopLevels</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopInfo"><span class="hs-identifier">loopInfo</span></a></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-comment">--Construction/Misc</span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfg"><span class="hs-identifier">getCfg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfgProc"><span class="hs-identifier">getCfgProc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier">pprEdgeWeights</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#sanityCheckCfg"><span class="hs-identifier">sanityCheckCfg</span></a></span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-comment">--Find backedges and update their weight</span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#optimizeCFG"><span class="hs-identifier">optimizeCFG</span></a></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-identifier">mkGlobalWeights</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>     </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Cmm</span></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Switch.html"><span class="hs-identifier">GHC.Cmm.Switch</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Block</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Graph.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Graph</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">G</span></span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html"><span class="hs-identifier">GHC.Data.Graph.Directed</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.Dominators.html"><span class="hs-identifier">GHC.CmmToAsm.CFG.Dominators</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Dom</span></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Strict.html#"><span class="hs-identifier">Data.IntMap.Strict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier">IntMap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.html#"><span class="hs-identifier">Data.IntSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier">IntSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Strict.html#"><span class="hs-identifier">Data.IntMap.Strict</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IM</span></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.html#"><span class="hs-identifier">Data.Map</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">M</span></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.html#"><span class="hs-identifier">Data.IntSet</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IS</span></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">S</span></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.Tree.html#"><span class="hs-identifier">Data.Tree</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bifunctor.html#"><span class="hs-identifier">Data.Bifunctor</span></a></span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-77"></span><span class="hs-comment">-- DEBUGGING ONLY</span><span>
</span><span id="line-78"></span><span class="hs-comment">--import GHC.Cmm.DebugBlock</span><span>
</span><span id="line-79"></span><span class="hs-comment">--import GHC.Data.OrdList</span><span>
</span><span id="line-80"></span><span class="hs-comment">--import GHC.Cmm.DebugBlock.Trace</span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Ppr.html"><span class="hs-identifier">GHC.Cmm.Ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- For Outputable instances</span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">D</span></span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier">sort</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier">nub</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier">partition</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.STRef.Strict.html#"><span class="hs-identifier">Data.STRef.Strict</span></a></span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.html#"><span class="hs-identifier">Control.Monad.ST</span></a></span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.MArray.html#"><span class="hs-identifier">Data.Array.MArray</span></a></span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.ST.html#"><span class="hs-identifier">Data.Array.ST</span></a></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.IArray.html#"><span class="hs-identifier">Data.Array.IArray</span></a></span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Unsafe.html#"><span class="hs-identifier">Data.Array.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#unsafeFreeze"><span class="hs-identifier">unsafeFreeze</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#"><span class="hs-identifier">Data.Array.Base</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#unsafeRead"><span class="hs-identifier">unsafeRead</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier">unsafeWrite</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-95"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.UnionFind.html"><span class="hs-identifier">GHC.Data.UnionFind</span></a></span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span class="hs-keyword">type</span><span> </span><span id="Prob"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-var">Prob</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-keyword">type</span><span> </span><span id="Edge"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-var">Edge</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-keyword">type</span><span> </span><span id="Edges"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edges"><span class="hs-identifier hs-var">Edges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-keyword">newtype</span><span> </span><span id="EdgeWeight"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-var">EdgeWeight</span></a></span></span><span>
</span><span id="line-103"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="EdgeWeight"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-var">EdgeWeight</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="weightToDouble"><span class="annot"><span class="annottext">EdgeWeight -&gt; Double
</span><a href="GHC.CmmToAsm.CFG.html#weightToDouble"><span class="hs-identifier hs-var hs-var">weightToDouble</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681021095"><span id="local-6989586621681021099"><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
(EdgeWeight -&gt; EdgeWeight -&gt; Bool)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Bool) -&gt; Eq EdgeWeight
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c/= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
== :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c== :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span id="local-6989586621681021064"><span id="local-6989586621681021068"><span id="local-6989586621681021072"><span id="local-6989586621681021076"><span id="local-6989586621681021080"><span id="local-6989586621681021084"><span id="local-6989586621681021088"><span class="annot"><span class="annottext">Eq EdgeWeight
Eq EdgeWeight
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Ordering)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Bool)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Bool)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Bool)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; Bool)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; Ord EdgeWeight
EdgeWeight -&gt; EdgeWeight -&gt; Bool
EdgeWeight -&gt; EdgeWeight -&gt; Ordering
EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
min :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$cmin :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
max :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$cmax :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
&gt;= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c&gt;= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
&gt; :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c&gt; :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
&lt;= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c&lt;= :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
&lt; :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
$c&lt; :: EdgeWeight -&gt; EdgeWeight -&gt; Bool
compare :: EdgeWeight -&gt; EdgeWeight -&gt; Ordering
$ccompare :: EdgeWeight -&gt; EdgeWeight -&gt; Ordering
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></span></span></span></span></span></span></span></span><span class="hs-special">,</span><span id="local-6989586621681021030"><span id="local-6989586621681021034"><span id="local-6989586621681021038"><span id="local-6989586621681021042"><span id="local-6989586621681021046"><span id="local-6989586621681021050"><span id="local-6989586621681021054"><span id="local-6989586621681021059"><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
EdgeWeight -&gt; Int
EdgeWeight -&gt; [EdgeWeight]
EdgeWeight -&gt; EdgeWeight
EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
(EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight)
-&gt; (Int -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; Int)
-&gt; (EdgeWeight -&gt; [EdgeWeight])
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight])
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight])
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight])
-&gt; Enum EdgeWeight
forall a.
(a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (Int -&gt; a)
-&gt; (a -&gt; Int)
-&gt; (a -&gt; [a])
-&gt; (a -&gt; a -&gt; [a])
-&gt; (a -&gt; a -&gt; [a])
-&gt; (a -&gt; a -&gt; a -&gt; [a])
-&gt; Enum a
enumFromThenTo :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
$cenumFromThenTo :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
enumFromTo :: EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
$cenumFromTo :: EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
enumFromThen :: EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
$cenumFromThen :: EdgeWeight -&gt; EdgeWeight -&gt; [EdgeWeight]
enumFrom :: EdgeWeight -&gt; [EdgeWeight]
$cenumFrom :: EdgeWeight -&gt; [EdgeWeight]
fromEnum :: EdgeWeight -&gt; Int
$cfromEnum :: EdgeWeight -&gt; Int
toEnum :: Int -&gt; EdgeWeight
$ctoEnum :: Int -&gt; EdgeWeight
pred :: EdgeWeight -&gt; EdgeWeight
$cpred :: EdgeWeight -&gt; EdgeWeight
succ :: EdgeWeight -&gt; EdgeWeight
$csucc :: EdgeWeight -&gt; EdgeWeight
</span><a href="../../base/src/GHC.Enum.html#Enum"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Enum</span></a></span></span></span></span></span></span></span></span></span><span class="hs-special">,</span><span id="local-6989586621681021000"><span id="local-6989586621681021004"><span id="local-6989586621681021008"><span id="local-6989586621681021012"><span id="local-6989586621681021016"><span id="local-6989586621681021020"><span id="local-6989586621681021024"><span class="annot"><span class="annottext">Integer -&gt; EdgeWeight
EdgeWeight -&gt; EdgeWeight
EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
(EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight)
-&gt; (Integer -&gt; EdgeWeight)
-&gt; Num EdgeWeight
forall a.
(a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (Integer -&gt; a)
-&gt; Num a
fromInteger :: Integer -&gt; EdgeWeight
$cfromInteger :: Integer -&gt; EdgeWeight
signum :: EdgeWeight -&gt; EdgeWeight
$csignum :: EdgeWeight -&gt; EdgeWeight
abs :: EdgeWeight -&gt; EdgeWeight
$cabs :: EdgeWeight -&gt; EdgeWeight
negate :: EdgeWeight -&gt; EdgeWeight
$cnegate :: EdgeWeight -&gt; EdgeWeight
* :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$c* :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
- :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$c- :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
+ :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$c+ :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="../../base/src/GHC.Num.html#Num"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Num</span></a></span></span></span></span></span></span></span></span><span class="hs-special">,</span><span id="local-6989586621681020991"><span class="annot"><span class="annottext">Num EdgeWeight
Ord EdgeWeight
Num EdgeWeight
-&gt; Ord EdgeWeight -&gt; (EdgeWeight -&gt; Rational) -&gt; Real EdgeWeight
EdgeWeight -&gt; Rational
forall a. Num a -&gt; Ord a -&gt; (a -&gt; Rational) -&gt; Real a
toRational :: EdgeWeight -&gt; Rational
$ctoRational :: EdgeWeight -&gt; Rational
</span><a href="../../base/src/GHC.Real.html#Real"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Real</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020974"><span id="local-6989586621681020978"><span id="local-6989586621681020982"><span class="annot"><span class="annottext">Num EdgeWeight
Num EdgeWeight
-&gt; (EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight)
-&gt; (EdgeWeight -&gt; EdgeWeight)
-&gt; (Rational -&gt; EdgeWeight)
-&gt; Fractional EdgeWeight
Rational -&gt; EdgeWeight
EdgeWeight -&gt; EdgeWeight
EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a.
Num a
-&gt; (a -&gt; a -&gt; a) -&gt; (a -&gt; a) -&gt; (Rational -&gt; a) -&gt; Fractional a
fromRational :: Rational -&gt; EdgeWeight
$cfromRational :: Rational -&gt; EdgeWeight
recip :: EdgeWeight -&gt; EdgeWeight
$crecip :: EdgeWeight -&gt; EdgeWeight
/ :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
$c/ :: EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="../../base/src/GHC.Real.html#Fractional"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Fractional</span></a></span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020968"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-107"></span><span>  </span><span id="local-6989586621681020966"><span class="annot"><span class="annottext">ppr :: EdgeWeight -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span id="local-6989586621681020964"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020964"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#doublePrec"><span class="hs-identifier hs-var">doublePrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">5</span></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020964"><span class="hs-identifier hs-var">w</span></a></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-keyword">type</span><span> </span><span id="EdgeInfoMap"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfoMap"><span class="hs-identifier hs-var">EdgeInfoMap</span></a></span></span><span> </span><span id="local-6989586621681020961"><span class="annot"><a href="#local-6989586621681020961"><span class="hs-identifier hs-type">edgeInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681020961"><span class="hs-identifier hs-type">edgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-comment">-- | A control flow graph where edges have been annotated with a weight.</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- Implemented as IntMap (IntMap \&lt;edgeData&gt;)</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- We must uphold the invariant that for each edge A -&gt; B we must have:</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- A entry B in the outer map.</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- A entry B in the map we get when looking up A.</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- Maintaining this invariant is useful as any failed lookup now indicates</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- an actual error in code which might go unnoticed for a while</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- otherwise.</span><span>
</span><span id="line-119"></span><span class="hs-keyword">type</span><span> </span><span id="CFG"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-var">CFG</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfoMap"><span class="hs-identifier hs-type">EdgeInfoMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-keyword">data</span><span> </span><span id="CfgEdge"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-var">CfgEdge</span></a></span></span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="CfgEdge"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-var">CfgEdge</span></a></span></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="edgeFrom"><span class="annot"><span class="annottext">CfgEdge -&gt; Label
</span><a href="GHC.CmmToAsm.CFG.html#edgeFrom"><span class="hs-identifier hs-var hs-var">edgeFrom</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="edgeTo"><span class="annot"><span class="annottext">CfgEdge -&gt; Label
</span><a href="GHC.CmmToAsm.CFG.html#edgeTo"><span class="hs-identifier hs-var hs-var">edgeTo</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-125"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="edgeInfo"><span class="annot"><span class="annottext">CfgEdge -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#edgeInfo"><span class="hs-identifier hs-var hs-var">edgeInfo</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-comment">-- | Careful! Since we assume there is at most one edge from A to B</span><span>
</span><span id="line-129"></span><span class="hs-comment">--   the Eq instance does not consider weight.</span><span>
</span><span id="line-130"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020954"><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-131"></span><span>  </span><span id="local-6989586621681020950"><span class="annot"><span class="annottext">== :: CfgEdge -&gt; CfgEdge -&gt; Bool
</span><span class="hs-operator hs-var hs-var hs-var hs-var">(==)</span></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020949"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020949"><span class="hs-identifier hs-var">from1</span></a></span></span><span> </span><span id="local-6989586621681020948"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020948"><span class="hs-identifier hs-var">to1</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020947"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020947"><span class="hs-identifier hs-var">from2</span></a></span></span><span> </span><span id="local-6989586621681020946"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020946"><span class="hs-identifier hs-var">to2</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-132"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020949"><span class="hs-identifier hs-var">from1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020947"><span class="hs-identifier hs-var">from2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020948"><span class="hs-identifier hs-var">to1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020946"><span class="hs-identifier hs-var">to2</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | Edges are sorted ascending pointwise by weight, source and destination</span><span>
</span><span id="line-135"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020930"><span id="local-6989586621681020932"><span id="local-6989586621681020934"><span id="local-6989586621681020936"><span id="local-6989586621681020938"><span id="local-6989586621681020940"><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span></span></span></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-136"></span><span>  </span><span id="local-6989586621681020920"><span class="annot"><span class="annottext">compare :: CfgEdge -&gt; CfgEdge -&gt; Ordering
</span><span class="hs-identifier hs-var hs-var hs-var hs-var">compare</span></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020918"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020918"><span class="hs-identifier hs-var">from1</span></a></span></span><span> </span><span id="local-6989586621681020917"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020917"><span class="hs-identifier hs-var">to1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">edgeWeight :: EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020914"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020914"><span class="hs-identifier hs-var">weight1</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020913"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020913"><span class="hs-identifier hs-var">from2</span></a></span></span><span> </span><span id="local-6989586621681020912"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020912"><span class="hs-identifier hs-var">to2</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">edgeWeight :: EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020911"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020911"><span class="hs-identifier hs-var">weight2</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-138"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020914"><span class="hs-identifier hs-var">weight1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020911"><span class="hs-identifier hs-var">weight2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020914"><span class="hs-identifier hs-var">weight1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020911"><span class="hs-identifier hs-var">weight2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020918"><span class="hs-identifier hs-var">from1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020913"><span class="hs-identifier hs-var">from2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-139"></span><span>      </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020914"><span class="hs-identifier hs-var">weight1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020911"><span class="hs-identifier hs-var">weight2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020918"><span class="hs-identifier hs-var">from1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020913"><span class="hs-identifier hs-var">from2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020917"><span class="hs-identifier hs-var">to1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020912"><span class="hs-identifier hs-var">to2</span></a></span><span>
</span><span id="line-140"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">LT</span></span><span>
</span><span id="line-141"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020918"><span class="hs-identifier hs-var">from1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020913"><span class="hs-identifier hs-var">from2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020917"><span class="hs-identifier hs-var">to1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020912"><span class="hs-identifier hs-var">to2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020914"><span class="hs-identifier hs-var">weight1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020911"><span class="hs-identifier hs-var">weight2</span></a></span><span>
</span><span id="line-142"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">EQ</span></span><span>
</span><span id="line-143"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-144"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">GT</span></span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020906"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-147"></span><span>  </span><span id="local-6989586621681020902"><span class="annot"><span class="annottext">ppr :: CfgEdge -&gt; SDoc
</span><a href="#local-6989586621681020902"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020901"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020901"><span class="hs-identifier hs-var">from1</span></a></span></span><span> </span><span id="local-6989586621681020900"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020900"><span class="hs-identifier hs-var">to1</span></a></span></span><span> </span><span id="local-6989586621681020899"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020899"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020901"><span class="hs-identifier hs-var">from1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-(&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020899"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;)-&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020900"><span class="hs-identifier hs-var">to1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span class="hs-comment">-- | Can we trace back a edge to a specific Cmm Node</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- or has it been introduced during assembly codegen. We use this to maintain</span><span>
</span><span id="line-152"></span><span class="hs-comment">-- some information which would otherwise be lost during the</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- Cmm \&lt;-&gt; asm transition.</span><span>
</span><span id="line-154"></span><span class="hs-comment">-- See also Note [Inverting Conditional Branches]</span><span>
</span><span id="line-155"></span><span class="hs-keyword">data</span><span> </span><span id="TransitionSource"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TransitionSource"><span class="hs-identifier hs-var">TransitionSource</span></a></span></span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="CmmSource"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-var">CmmSource</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="trans_cmmNode"><span class="annot"><span class="annottext">TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var hs-var">trans_cmmNode</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span>              </span><span class="hs-special">,</span><span> </span><span id="trans_info"><span class="annot"><span class="annottext">TransitionSource -&gt; BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#trans_info"><span class="hs-identifier hs-var hs-var">trans_info</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BranchInfo"><span class="hs-identifier hs-type">BranchInfo</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="AsmCodeGen"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#AsmCodeGen"><span class="hs-identifier hs-var">AsmCodeGen</span></a></span></span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020884"><span id="local-6989586621681020889"><span class="annot"><span class="annottext">TransitionSource -&gt; TransitionSource -&gt; Bool
(TransitionSource -&gt; TransitionSource -&gt; Bool)
-&gt; (TransitionSource -&gt; TransitionSource -&gt; Bool)
-&gt; Eq TransitionSource
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: TransitionSource -&gt; TransitionSource -&gt; Bool
$c/= :: TransitionSource -&gt; TransitionSource -&gt; Bool
== :: TransitionSource -&gt; TransitionSource -&gt; Bool
$c== :: TransitionSource -&gt; TransitionSource -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-keyword">data</span><span> </span><span id="BranchInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BranchInfo"><span class="hs-identifier hs-var">BranchInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="NoInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#NoInfo"><span class="hs-identifier hs-var">NoInfo</span></a></span></span><span>         </span><span class="hs-comment">-- ^ Unknown, but not heap or stack check.</span><span>
</span><span id="line-162"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span id="HeapStackCheck"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#HeapStackCheck"><span class="hs-identifier hs-var">HeapStackCheck</span></a></span></span><span> </span><span class="hs-comment">-- ^ Heap or stack check</span><span>
</span><span id="line-163"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621681020878"><span id="local-6989586621681020880"><span class="annot"><span class="annottext">BranchInfo -&gt; BranchInfo -&gt; Bool
(BranchInfo -&gt; BranchInfo -&gt; Bool)
-&gt; (BranchInfo -&gt; BranchInfo -&gt; Bool) -&gt; Eq BranchInfo
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: BranchInfo -&gt; BranchInfo -&gt; Bool
$c/= :: BranchInfo -&gt; BranchInfo -&gt; Bool
== :: BranchInfo -&gt; BranchInfo -&gt; Bool
$c== :: BranchInfo -&gt; BranchInfo -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020875"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BranchInfo"><span class="hs-identifier hs-type">BranchInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-166"></span><span>    </span><span id="local-6989586621681020874"><span class="annot"><span class="annottext">ppr :: BranchInfo -&gt; SDoc
</span><a href="#local-6989586621681020874"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#NoInfo"><span class="hs-identifier hs-var">NoInfo</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;regular&quot;</span></span><span>
</span><span id="line-167"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#HeapStackCheck"><span class="hs-identifier hs-var">HeapStackCheck</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;heap/stack&quot;</span></span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-type">isHeapOrStackCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TransitionSource"><span class="hs-identifier hs-type">TransitionSource</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-170"></span><span id="isHeapOrStackCheck"><span class="annot"><span class="annottext">isHeapOrStackCheck :: TransitionSource -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var hs-var">isHeapOrStackCheck</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_info :: TransitionSource -&gt; BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#trans_info"><span class="hs-identifier hs-var">trans_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#HeapStackCheck"><span class="hs-identifier hs-var">HeapStackCheck</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-171"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var">isHeapOrStackCheck</span></a></span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-172"></span><span>
</span><span id="line-173"></span><span class="hs-comment">-- | Information about edges</span><span>
</span><span id="line-174"></span><span class="hs-keyword">data</span><span> </span><span id="EdgeInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-var">EdgeInfo</span></a></span></span><span>
</span><span id="line-175"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="EdgeInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-var">EdgeInfo</span></a></span></span><span>
</span><span id="line-176"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="transitionSource"><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TransitionSource"><span class="hs-identifier hs-type">TransitionSource</span></a></span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="edgeWeight"><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-178"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020866"><span id="local-6989586621681020870"><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeInfo -&gt; Bool
(EdgeInfo -&gt; EdgeInfo -&gt; Bool)
-&gt; (EdgeInfo -&gt; EdgeInfo -&gt; Bool) -&gt; Eq EdgeInfo
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: EdgeInfo -&gt; EdgeInfo -&gt; Bool
$c/= :: EdgeInfo -&gt; EdgeInfo -&gt; Bool
== :: EdgeInfo -&gt; EdgeInfo -&gt; Bool
$c== :: EdgeInfo -&gt; EdgeInfo -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020863"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-181"></span><span>  </span><span id="local-6989586621681020861"><span class="annot"><span class="annottext">ppr :: EdgeInfo -&gt; SDoc
</span><a href="#local-6989586621681020861"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span id="local-6989586621681020860"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020860"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;weight:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020860"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span class="hs-comment">-- | Convenience function, generate edge info based</span><span>
</span><span id="line-184"></span><span class="hs-comment">--   on weight not originating from cmm.</span><span>
</span><span id="line-185"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkWeightInfo"><span class="hs-identifier hs-type">mkWeightInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span>
</span><span id="line-186"></span><span id="mkWeightInfo"><span class="annot"><span class="annottext">mkWeightInfo :: EdgeWeight -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#mkWeightInfo"><span class="hs-identifier hs-var hs-var">mkWeightInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TransitionSource -&gt; EdgeWeight -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-var">EdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#AsmCodeGen"><span class="hs-identifier hs-var">AsmCodeGen</span></a></span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span class="hs-comment">-- | Adjust the weight between the blocks using the given function.</span><span>
</span><span id="line-189"></span><span class="hs-comment">--   If there is no such edge returns the original map.</span><span>
</span><span id="line-190"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#adjustEdgeWeight"><span class="hs-identifier hs-type">adjustEdgeWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-191"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-192"></span><span id="adjustEdgeWeight"><span class="annot"><span class="annottext">adjustEdgeWeight :: CFG -&gt; (EdgeWeight -&gt; EdgeWeight) -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#adjustEdgeWeight"><span class="hs-identifier hs-var hs-var">adjustEdgeWeight</span></a></span></span><span> </span><span id="local-6989586621681020859"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020859"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020858"><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020858"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681020857"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020857"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020856"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020856"><span class="hs-identifier hs-var">to</span></a></span></span><span>
</span><span id="line-193"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020855"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020855"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020857"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020856"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020859"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020854"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020854"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020855"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020853"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020853"><span class="hs-identifier hs-var">newWeight</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020858"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020854"><span class="hs-identifier hs-var">weight</span></a></span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020857"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020856"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020855"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020853"><span class="hs-identifier hs-var">newWeight</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020859"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020859"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-comment">-- | Set the weight between the blocks to the given weight.</span><span>
</span><span id="line-200"></span><span class="hs-comment">--   If there is no such edge returns the original map.</span><span>
</span><span id="line-201"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-type">setEdgeWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-202"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-203"></span><span id="setEdgeWeight"><span class="annot"><span class="annottext">setEdgeWeight :: CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var hs-var">setEdgeWeight</span></a></span></span><span> </span><span id="local-6989586621681020852"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020852"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020851"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020851"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span id="local-6989586621681020850"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020850"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020849"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020849"><span class="hs-identifier hs-var">to</span></a></span></span><span>
</span><span id="line-204"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020848"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020848"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020850"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020849"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020852"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020850"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020849"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020848"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020851"><span class="hs-identifier hs-var">weight</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020852"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020852"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-type">getCfgNodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-210"></span><span id="getCfgNodes"><span class="annot"><span class="annottext">getCfgNodes :: CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var hs-var">getCfgNodes</span></a></span></span><span> </span><span id="local-6989586621681020847"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020847"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-211"></span><span>    </span><span class="annot"><span class="annottext">CFG -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020847"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span class="hs-comment">-- | Is this block part of this graph?</span><span>
</span><span id="line-214"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#hasNode"><span class="hs-identifier hs-type">hasNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-215"></span><span id="hasNode"><span class="annot"><span class="annottext">hasNode :: CFG -&gt; Label -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#hasNode"><span class="hs-identifier hs-var hs-var">hasNode</span></a></span></span><span> </span><span id="local-6989586621681020845"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020845"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020844"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020844"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-216"></span><span>  </span><span class="hs-comment">-- Check the invariant that each node must exist in the first map or not at all.</span><span>
</span><span id="line-217"></span><span>  </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">found</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">any</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">mapMember</span><span> </span><span class="hs-identifier">node</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681020841"><span class="hs-identifier hs-var">found</span></a></span><span>
</span><span id="line-219"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-220"></span><span>      </span><span id="local-6989586621681020841"><span class="annot"><span class="annottext">found :: Bool
</span><a href="#local-6989586621681020841"><span class="hs-identifier hs-var hs-var">found</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; CFG -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020844"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020845"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="hs-comment">-- | Check if the nodes in the cfg and the set of blocks are the same.</span><span>
</span><span id="line-225"></span><span class="hs-comment">--   In a case of a missmatch we panic and show the difference.</span><span>
</span><span id="line-226"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#sanityCheckCfg"><span class="hs-identifier hs-type">sanityCheckCfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-227"></span><span id="sanityCheckCfg"><span class="annot"><span class="annottext">sanityCheckCfg :: CFG -&gt; LabelSet -&gt; SDoc -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#sanityCheckCfg"><span class="hs-identifier hs-var hs-var">sanityCheckCfg</span></a></span></span><span> </span><span id="local-6989586621681020837"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020837"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020836"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020836"><span class="hs-identifier hs-var">blockSet</span></a></span></span><span> </span><span id="local-6989586621681020835"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681020835"><span class="hs-identifier hs-var">msg</span></a></span></span><span>
</span><span id="line-228"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020836"><span class="hs-identifier hs-var">blockSet</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020834"><span class="hs-identifier hs-var">cfgNodes</span></a></span><span>
</span><span id="line-229"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-230"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-231"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Bool -&gt; Bool
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Block list and cfg nodes don't match&quot;</span></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-232"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;difference:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020832"><span class="hs-identifier hs-var">diff</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-233"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;blocks:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020836"><span class="hs-identifier hs-var">blockSet</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-234"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cfg:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; SDoc
</span><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-var">pprEdgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020837"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-235"></span><span>            </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681020835"><span class="hs-identifier hs-var">msg</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-236"></span><span>            </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-237"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-238"></span><span>      </span><span id="local-6989586621681020834"><span class="annot"><span class="annottext">cfgNodes :: LabelSet
</span><a href="#local-6989586621681020834"><span class="hs-identifier hs-var hs-var">cfgNodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([ElemOf LabelSet] -&gt; LabelSet) -&gt; [ElemOf LabelSet] -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020837"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-239"></span><span>      </span><span id="local-6989586621681020832"><span class="annot"><span class="annottext">diff :: LabelSet
</span><a href="#local-6989586621681020832"><span class="hs-identifier hs-var hs-var">diff</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setUnion"><span class="hs-identifier hs-var">setUnion</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020834"><span class="hs-identifier hs-var">cfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020836"><span class="hs-identifier hs-var">blockSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setDifference"><span class="hs-operator hs-var">`setDifference`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setIntersection"><span class="hs-identifier hs-var">setIntersection</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020834"><span class="hs-identifier hs-var">cfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020836"><span class="hs-identifier hs-var">blockSet</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="hs-comment">-- | Filter the CFG with a custom function f.</span><span>
</span><span id="line-242"></span><span class="hs-comment">--   Paramaeters are `f from to edgeInfo`</span><span>
</span><span id="line-243"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#filterEdges"><span class="hs-identifier hs-type">filterEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-244"></span><span id="filterEdges"><span class="annot"><span class="annottext">filterEdges :: (Label -&gt; Label -&gt; EdgeInfo -&gt; Bool) -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#filterEdges"><span class="hs-identifier hs-var hs-var">filterEdges</span></a></span></span><span> </span><span id="local-6989586621681020826"><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; Bool
</span><a href="#local-6989586621681020826"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681020825"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020825"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-245"></span><span>    </span><span class="annot"><span class="annottext">(KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo)
-&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a b.
IsMap map =&gt;
(KeyOf map -&gt; a -&gt; b) -&gt; map a -&gt; map b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMapWithKey"><span class="hs-identifier hs-var">mapMapWithKey</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
Label -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
</span><a href="#local-6989586621681020823"><span class="hs-identifier hs-var">filterSources</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020825"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-246"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-247"></span><span>      </span><span id="local-6989586621681020823"><span class="annot"><span class="annottext">filterSources :: Label -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
</span><a href="#local-6989586621681020823"><span class="hs-identifier hs-var hs-var">filterSources</span></a></span></span><span> </span><span id="local-6989586621681020822"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020822"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020821"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020821"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-248"></span><span>        </span><span class="annot"><span class="annottext">(KeyOf LabelMap -&gt; EdgeInfo -&gt; Bool)
-&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(KeyOf map -&gt; a -&gt; Bool) -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFilterWithKey"><span class="hs-identifier hs-var">mapFilterWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020819"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681020819"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020818"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020818"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; Bool
</span><a href="#local-6989586621681020826"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020822"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020819"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020818"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020821"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span class="hs-comment">{- Note [Updating the CFG during shortcutting]

See Note [What is shortcutting] in the control flow optimization
code (GHC.Cmm.ContFlowOpt) for a slightly more in depth explanation on shortcutting.

In the native backend we shortcut jumps at the assembly level. (&quot;GHC.CmmToAsm&quot;)
This means we remove blocks containing only one jump from the code
and instead redirecting all jumps targeting this block to the deleted
blocks jump target.

However we want to have an accurate representation of control
flow in the CFG. So we add/remove edges accordingly to account
for the eliminated blocks and new edges.

If we shortcut A -&gt; B -&gt; C to A -&gt; C:
* We delete edges A -&gt; B and B -&gt; C
* Replacing them with the edge A -&gt; C

We also try to preserve jump weights while doing so.

Note that:
* The edge B -&gt; C can't have interesting weights since
  the block B consists of a single unconditional jump without branching.
* We delete the edge A -&gt; B and add the edge A -&gt; C.
* The edge A -&gt; B can be one of many edges originating from A so likely
  has edge weights we want to preserve.

For this reason we simply store the edge info from the original A -&gt; B
edge and apply this information to the new edge A -&gt; C.

Sometimes we have a scenario where jump target C is not represented by an
BlockId but an immediate value. I'm only aware of this happening without
tables next to code currently.

Then we go from A ---&gt; B - -&gt; IMM   to   A - -&gt; IMM where the dashed arrows
are not stored in the CFG.

In that case we simply delete the edge A -&gt; B.

In terms of implementation the native backend first builds a mapping
from blocks suitable for shortcutting to their jump targets.
Then it redirects all jump instructions to these blocks using the
built up mapping.
This function (shortcutWeightMap) takes the same mapping and
applies the mapping to the CFG in the way laid out above.

-}</span><span>
</span><span id="line-298"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#shortcutWeightMap"><span class="hs-identifier hs-type">shortcutWeightMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-299"></span><span id="shortcutWeightMap"><span class="annot"><span class="annottext">shortcutWeightMap :: LabelMap (Maybe Label) -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#shortcutWeightMap"><span class="hs-identifier hs-var hs-var">shortcutWeightMap</span></a></span></span><span> </span><span id="local-6989586621681020817"><span class="annot"><span class="annottext">LabelMap (Maybe Label)
</span><a href="#local-6989586621681020817"><span class="hs-identifier hs-var">cuts</span></a></span></span><span> </span><span id="local-6989586621681020816"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020816"><span class="hs-identifier hs-var">cfg</span></a></span></span><span>
</span><span id="line-300"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label) -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapNull"><span class="hs-identifier hs-var">mapNull</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label)
</span><a href="#local-6989586621681020817"><span class="hs-identifier hs-var">cuts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020816"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-301"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020814"><span class="hs-identifier hs-var">normalised_cfg</span></a></span><span>
</span><span id="line-302"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-303"></span><span>      </span><span class="hs-comment">-- First take the cuts map and collapse any shortcuts, for example</span><span>
</span><span id="line-304"></span><span>      </span><span class="hs-comment">-- if the cuts map has A -&gt; B and B -&gt; C then we want to rewrite</span><span>
</span><span id="line-305"></span><span>      </span><span class="hs-comment">-- A -&gt; C and B -&gt; C directly.</span><span>
</span><span id="line-306"></span><span>      </span><span class="annot"><a href="#local-6989586621681020813"><span class="hs-identifier hs-type">normalised_cuts_st</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681021670"><span class="annot"><a href="#local-6989586621681021670"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021670"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-307"></span><span>      </span><span id="local-6989586621681020813"><span class="annot"><span class="annottext">normalised_cuts_st :: forall s. ST s (LabelMap (Maybe Label))
</span><a href="#local-6989586621681020813"><span class="hs-identifier hs-var hs-var">normalised_cuts_st</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-308"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681020788"><span class="annot"><span class="annottext">Point s (Maybe Label)
</span><a href="#local-6989586621681020788"><span class="hs-identifier hs-var">null</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.UnionFind.html#Point"><span class="hs-identifier hs-type">Point</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021670"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Label -&gt; ST s (Point s (Maybe Label))
forall a s. a -&gt; ST s (Point s a)
</span><a href="GHC.Data.UnionFind.html#fresh"><span class="hs-identifier hs-var">fresh</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Label
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-309"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020786"><span class="annot"><span class="annottext">cuts_list :: [(KeyOf LabelMap, Maybe Label)]
</span><a href="#local-6989586621681020786"><span class="hs-identifier hs-var hs-var">cuts_list</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label) -&gt; [(KeyOf LabelMap, Maybe Label)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label)
</span><a href="#local-6989586621681020817"><span class="hs-identifier hs-var">cuts</span></a></span><span>
</span><span id="line-310"></span><span>        </span><span class="hs-comment">-- Create a unification variable for each of the nodes in a rewrite</span><span>
</span><span id="line-311"></span><span>        </span><span id="local-6989586621681020784"><span class="annot"><span class="annottext">[(Label, Point s (Maybe Label))]
</span><a href="#local-6989586621681020784"><span class="hs-identifier hs-var">cuts_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; ST s (Label, Point s (Maybe Label)))
-&gt; [Label] -&gt; ST s [(Label, Point s (Maybe Label))]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020782"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020782"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020782"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Point s (Maybe Label) -&gt; (Label, Point s (Maybe Label)))
-&gt; ST s (Point s (Maybe Label))
-&gt; ST s (Label, Point s (Maybe Label))
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Label -&gt; ST s (Point s (Maybe Label))
forall a s. a -&gt; ST s (Point s a)
</span><a href="GHC.Data.UnionFind.html#fresh"><span class="hs-identifier hs-var">fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Maybe Label
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020782"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Label, Maybe Label) -&gt; [Label])
-&gt; [(Label, Maybe Label)] -&gt; [Label]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681020779"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020779"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020778"><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020778"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020779"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [Label] -&gt; [Label]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; (Label -&gt; [Label]) -&gt; Maybe Label -&gt; [Label]
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; [Label] -&gt; [Label]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020778"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Maybe Label)]
[(Label, Maybe Label)]
</span><a href="#local-6989586621681020786"><span class="hs-identifier hs-var">cuts_list</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020776"><span class="annot"><span class="annottext">cuts_map :: LabelMap (Point s (Maybe Label))
</span><a href="#local-6989586621681020776"><span class="hs-identifier hs-var hs-var">cuts_map</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Point s (Maybe Label))]
-&gt; LabelMap (Point s (Maybe Label))
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Point s (Maybe Label))]
[(Label, Point s (Maybe Label))]
</span><a href="#local-6989586621681020784"><span class="hs-identifier hs-var">cuts_vars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.UnionFind.html#Point"><span class="hs-identifier hs-type">Point</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021670"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>        </span><span class="hs-comment">-- Then unify according the the rewrites in the cuts map</span><span>
</span><span id="line-314"></span><span>        </span><span class="annot"><span class="annottext">((Label, Maybe Label) -&gt; ST s ())
-&gt; [(Label, Maybe Label)] -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681020773"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020773"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020772"><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020772"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (Point s (Maybe Label)) -&gt; Point s (Maybe Label)
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;shortcutWeightMap&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; LabelMap (Point s (Maybe Label))
-&gt; Maybe (Point s (Maybe Label))
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020773"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s (Maybe Label))
</span><a href="#local-6989586621681020776"><span class="hs-identifier hs-var">cuts_map</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-315"></span><span>                              </span><span class="annot"><span class="annottext">Point s (Maybe Label) -&gt; Point s (Maybe Label) -&gt; ST s ()
forall s a. Point s a -&gt; Point s a -&gt; ST s ()
</span><a href="GHC.Data.UnionFind.html#union"><span class="hs-operator hs-var">`union`</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (Point s (Maybe Label)) -&gt; Point s (Maybe Label)
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;shortcutWeightMap&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Point s (Maybe Label))
-&gt; (Label -&gt; Maybe (Point s (Maybe Label)))
-&gt; Maybe Label
-&gt; Maybe (Point s (Maybe Label))
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Point s (Maybe Label) -&gt; Maybe (Point s (Maybe Label))
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (Maybe Label)
</span><a href="#local-6989586621681020788"><span class="hs-identifier hs-var">null</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Label
 -&gt; LabelMap (Point s (Maybe Label))
 -&gt; Maybe (Point s (Maybe Label)))
-&gt; LabelMap (Point s (Maybe Label))
-&gt; Label
-&gt; Maybe (Point s (Maybe Label))
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Label
-&gt; LabelMap (Point s (Maybe Label))
-&gt; Maybe (Point s (Maybe Label))
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s (Maybe Label))
</span><a href="#local-6989586621681020776"><span class="hs-identifier hs-var">cuts_map</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020772"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Maybe Label)]
[(Label, Maybe Label)]
</span><a href="#local-6989586621681020786"><span class="hs-identifier hs-var">cuts_list</span></a></span><span>
</span><span id="line-316"></span><span>        </span><span class="hs-comment">-- Then recover the unique representative, which is the result of following</span><span>
</span><span id="line-317"></span><span>        </span><span class="hs-comment">-- the chain to the end.</span><span>
</span><span id="line-318"></span><span>        </span><span class="annot"><span class="annottext">(Point s (Maybe Label) -&gt; ST s (Maybe Label))
-&gt; LabelMap (Point s (Maybe Label))
-&gt; ST s (LabelMap (Maybe Label))
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (Maybe Label) -&gt; ST s (Maybe Label)
forall s a. Point s a -&gt; ST s a
</span><a href="GHC.Data.UnionFind.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Point s (Maybe Label))
</span><a href="#local-6989586621681020776"><span class="hs-identifier hs-var">cuts_map</span></a></span><span>
</span><span id="line-319"></span><span>
</span><span id="line-320"></span><span>      </span><span id="local-6989586621681020765"><span class="annot"><span class="annottext">normalised_cuts :: LabelMap (Maybe Label)
</span><a href="#local-6989586621681020765"><span class="hs-identifier hs-var hs-var">normalised_cuts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s (LabelMap (Maybe Label))) -&gt; LabelMap (Maybe Label)
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">forall s. ST s (LabelMap (Maybe Label))
</span><a href="#local-6989586621681020813"><span class="hs-identifier hs-var">normalised_cuts_st</span></a></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span>      </span><span class="annot"><a href="#local-6989586621681020763"><span class="hs-identifier hs-type">cuts_domain</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-323"></span><span>      </span><span id="local-6989586621681020763"><span class="annot"><span class="annottext">cuts_domain :: LabelSet
</span><a href="#local-6989586621681020763"><span class="hs-identifier hs-var hs-var">cuts_domain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([ElemOf LabelSet] -&gt; LabelSet) -&gt; [ElemOf LabelSet] -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label) -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label)
</span><a href="#local-6989586621681020817"><span class="hs-identifier hs-var">cuts</span></a></span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span>      </span><span class="hs-comment">-- The CFG is shortcutted using the normalised cuts map</span><span>
</span><span id="line-326"></span><span>      </span><span class="annot"><a href="#local-6989586621681020814"><span class="hs-identifier hs-type">normalised_cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-327"></span><span>      </span><span id="local-6989586621681020814"><span class="annot"><span class="annottext">normalised_cfg :: CFG
</span><a href="#local-6989586621681020814"><span class="hs-identifier hs-var hs-var">normalised_cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; CFG)
-&gt; CFG -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; CFG
CFG -&gt; Label -&gt; LabelMap EdgeInfo -&gt; CFG
</span><a href="#local-6989586621681020761"><span class="hs-identifier hs-var">update_edge</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020816"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span>      </span><span class="annot"><a href="#local-6989586621681020761"><span class="hs-identifier hs-type">update_edge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-330"></span><span>      </span><span id="local-6989586621681020761"><span class="annot"><span class="annottext">update_edge :: CFG -&gt; Label -&gt; LabelMap EdgeInfo -&gt; CFG
</span><a href="#local-6989586621681020761"><span class="hs-identifier hs-var hs-var">update_edge</span></a></span></span><span> </span><span id="local-6989586621681020759"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020759"><span class="hs-identifier hs-var">new_map</span></a></span></span><span> </span><span id="local-6989586621681020758"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020758"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020757"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020757"><span class="hs-identifier hs-var">edge_map</span></a></span></span><span>
</span><span id="line-331"></span><span>        </span><span class="hs-comment">-- If the from edge is in the cuts map then delete the edge</span><span>
</span><span id="line-332"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020758"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020763"><span class="hs-identifier hs-var">cuts_domain</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020759"><span class="hs-identifier hs-var">new_map</span></a></span><span>
</span><span id="line-333"></span><span>        </span><span class="hs-comment">-- Otherwise we are keeping the edge, but might have shortcutted some of</span><span>
</span><span id="line-334"></span><span>        </span><span class="hs-comment">-- the target nodes.</span><span>
</span><span id="line-335"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020758"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LabelMap EdgeInfo
 -&gt; KeyOf LabelMap -&gt; EdgeInfo -&gt; LabelMap EdgeInfo)
-&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
-&gt; KeyOf LabelMap -&gt; EdgeInfo -&gt; LabelMap EdgeInfo
forall a. LabelMap a -&gt; Label -&gt; a -&gt; LabelMap a
</span><a href="#local-6989586621681020754"><span class="hs-identifier hs-var">update_from_edge</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020757"><span class="hs-identifier hs-var">edge_map</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020759"><span class="hs-identifier hs-var">new_map</span></a></span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span>      </span><span id="local-6989586621681021624"><span class="annot"><a href="#local-6989586621681020754"><span class="hs-identifier hs-type">update_from_edge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021624"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681021624"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021624"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-338"></span><span>      </span><span id="local-6989586621681020754"><span class="annot"><span class="annottext">update_from_edge :: forall a. LabelMap a -&gt; Label -&gt; a -&gt; LabelMap a
</span><a href="#local-6989586621681020754"><span class="hs-identifier hs-var hs-var">update_from_edge</span></a></span></span><span> </span><span id="local-6989586621681020750"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020750"><span class="hs-identifier hs-var">new_map</span></a></span></span><span> </span><span id="local-6989586621681020749"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020749"><span class="hs-identifier hs-var">to_edge</span></a></span></span><span> </span><span id="local-6989586621681020748"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020748"><span class="hs-identifier hs-var">edge_info</span></a></span></span><span>
</span><span id="line-339"></span><span>        </span><span class="hs-comment">-- Edge is in the normalised cuts</span><span>
</span><span id="line-340"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020747"><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020747"><span class="hs-identifier hs-var">new_edge</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap (Maybe Label) -&gt; Maybe (Maybe Label)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020749"><span class="hs-identifier hs-var">to_edge</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (Maybe Label)
</span><a href="#local-6989586621681020765"><span class="hs-identifier hs-var">normalised_cuts</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-341"></span><span>            </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Label
</span><a href="#local-6989586621681020747"><span class="hs-identifier hs-var">new_edge</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-342"></span><span>              </span><span class="hs-comment">-- The result was Nothing, so edge is deleted</span><span>
</span><span id="line-343"></span><span>              </span><span class="annot"><span class="annottext">Maybe Label
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020750"><span class="hs-identifier hs-var">new_map</span></a></span><span>
</span><span id="line-344"></span><span>              </span><span class="hs-comment">-- The new target for the edge, write it with the old edge_info.</span><span>
</span><span id="line-345"></span><span>              </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020746"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020746"><span class="hs-identifier hs-var">new_to</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; a -&gt; LabelMap a -&gt; LabelMap a
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020746"><span class="hs-identifier hs-var">new_to</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020748"><span class="hs-identifier hs-var">edge_info</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020750"><span class="hs-identifier hs-var">new_map</span></a></span><span>
</span><span id="line-346"></span><span>        </span><span class="hs-comment">-- Node wasn't in the cuts map, so just add it back</span><span>
</span><span id="line-347"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; a -&gt; LabelMap a -&gt; LabelMap a
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020749"><span class="hs-identifier hs-var">to_edge</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020748"><span class="hs-identifier hs-var">edge_info</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020750"><span class="hs-identifier hs-var">new_map</span></a></span><span>
</span><span id="line-348"></span><span>
</span><span id="line-349"></span><span>
</span><span id="line-350"></span><span class="hs-comment">-- | Sometimes we insert a block which should unconditionally be executed</span><span>
</span><span id="line-351"></span><span class="hs-comment">--   after a given block. This function updates the CFG for these cases.</span><span>
</span><span id="line-352"></span><span class="hs-comment">--  So we get A -&gt; B    =&gt; A -&gt; A' -&gt; B</span><span>
</span><span id="line-353"></span><span class="hs-comment">--             \                  \</span><span>
</span><span id="line-354"></span><span class="hs-comment">--              -&gt; C    =&gt;         -&gt; C</span><span>
</span><span id="line-355"></span><span class="hs-comment">--</span><span>
</span><span id="line-356"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addImmediateSuccessor"><span class="hs-identifier hs-type">addImmediateSuccessor</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">D.DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-357"></span><span id="addImmediateSuccessor"><span class="annot"><span class="annottext">addImmediateSuccessor :: DynFlags -&gt; Label -&gt; Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addImmediateSuccessor"><span class="hs-identifier hs-var hs-var">addImmediateSuccessor</span></a></span></span><span> </span><span id="local-6989586621681020745"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681020745"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681020744"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020744"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681020743"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020743"><span class="hs-identifier hs-var">follower</span></a></span></span><span> </span><span id="local-6989586621681020742"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020742"><span class="hs-identifier hs-var">cfg</span></a></span></span><span>
</span><span id="line-358"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="#local-6989586621681020741"><span class="hs-identifier hs-var">updateEdges</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeWeight -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addWeightEdge"><span class="hs-identifier hs-var">addWeightEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020744"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020743"><span class="hs-identifier hs-var">follower</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020739"><span class="hs-identifier hs-var">uncondWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020742"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-359"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-360"></span><span>        </span><span id="local-6989586621681020739"><span class="annot"><span class="annottext">uncondWeight :: EdgeWeight
</span><a href="#local-6989586621681020739"><span class="hs-identifier hs-var hs-var">uncondWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; EdgeWeight) -&gt; (DynFlags -&gt; Int) -&gt; DynFlags -&gt; EdgeWeight
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#uncondWeight"><span class="hs-identifier hs-var hs-var">D.uncondWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(CfgWeights -&gt; Int) -&gt; (DynFlags -&gt; CfgWeights) -&gt; DynFlags -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-361"></span><span>                       </span><span class="annot"><span class="annottext">DynFlags -&gt; CfgWeights
</span><a href="GHC.Driver.Session.html#cfgWeightInfo"><span class="hs-identifier hs-var hs-var">D.cfgWeightInfo</span></a></span><span> </span><span class="annot"><span class="annottext">(DynFlags -&gt; EdgeWeight) -&gt; DynFlags -&gt; EdgeWeight
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681020745"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-362"></span><span>        </span><span id="local-6989586621681020736"><span class="annot"><span class="annottext">targets :: [(Label, EdgeInfo)]
</span><a href="#local-6989586621681020736"><span class="hs-identifier hs-var hs-var">targets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-var">getSuccessorEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020742"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020744"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-363"></span><span>        </span><span id="local-6989586621681020735"><span class="annot"><span class="annottext">successors :: [Label]
</span><a href="#local-6989586621681020735"><span class="hs-identifier hs-var hs-var">successors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Label) -&gt; [(Label, EdgeInfo)] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020736"><span class="hs-identifier hs-var">targets</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-364"></span><span>        </span><span id="local-6989586621681020741"><span class="annot"><span class="annottext">updateEdges :: CFG -&gt; CFG
</span><a href="#local-6989586621681020741"><span class="hs-identifier hs-var hs-var">updateEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="#local-6989586621681020734"><span class="hs-identifier hs-var">addNewSuccs</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="#local-6989586621681020733"><span class="hs-identifier hs-var">remOldSuccs</span></a></span><span>
</span><span id="line-365"></span><span>        </span><span id="local-6989586621681020733"><span class="annot"><span class="annottext">remOldSuccs :: CFG -&gt; CFG
</span><a href="#local-6989586621681020733"><span class="hs-identifier hs-var hs-var">remOldSuccs</span></a></span></span><span> </span><span id="local-6989586621681020732"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020732"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; Label -&gt; CFG) -&gt; CFG -&gt; [Label] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Label -&gt; CFG -&gt; CFG) -&gt; CFG -&gt; Label -&gt; CFG
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#delEdge"><span class="hs-identifier hs-var">delEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020744"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020732"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020735"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-366"></span><span>        </span><span id="local-6989586621681020734"><span class="annot"><span class="annottext">addNewSuccs :: CFG -&gt; CFG
</span><a href="#local-6989586621681020734"><span class="hs-identifier hs-var hs-var">addNewSuccs</span></a></span></span><span> </span><span id="local-6989586621681020730"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020730"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-367"></span><span>          </span><span class="annot"><span class="annottext">(CFG -&gt; (Label, EdgeInfo) -&gt; CFG)
-&gt; CFG -&gt; [(Label, EdgeInfo)] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020729"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020729"><span class="hs-identifier hs-var">m'</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020728"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020728"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020727"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020727"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020743"><span class="hs-identifier hs-var">follower</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020728"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020727"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020729"><span class="hs-identifier hs-var">m'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020730"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020736"><span class="hs-identifier hs-var">targets</span></a></span><span>
</span><span id="line-368"></span><span>
</span><span id="line-369"></span><span class="hs-comment">-- | Adds a new edge, overwrites existing edges if present</span><span>
</span><span id="line-370"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-type">addEdge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-371"></span><span id="addEdge"><span class="annot"><span class="annottext">addEdge :: Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var hs-var">addEdge</span></a></span></span><span> </span><span id="local-6989586621681020726"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020726"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020725"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020725"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020724"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020724"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681020723"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020723"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-372"></span><span>    </span><span class="annot"><span class="annottext">(Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo))
-&gt; KeyOf LabelMap -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(Maybe a -&gt; Maybe a) -&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapAlter"><span class="hs-identifier hs-var">mapAlter</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020721"><span class="hs-identifier hs-var">addFromToEdge</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020726"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-373"></span><span>    </span><span class="annot"><span class="annottext">(Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo))
-&gt; KeyOf LabelMap -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(Maybe a -&gt; Maybe a) -&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapAlter"><span class="hs-identifier hs-var">mapAlter</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
forall {map :: * -&gt; *} {a}.
IsMap map =&gt;
Maybe (map a) -&gt; Maybe (map a)
</span><a href="#local-6989586621681020720"><span class="hs-identifier hs-var">addDestNode</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020725"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020723"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-374"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-375"></span><span>        </span><span class="hs-comment">-- Simply insert the edge into the edge list.</span><span>
</span><span id="line-376"></span><span>        </span><span id="local-6989586621681020721"><span class="annot"><span class="annottext">addFromToEdge :: Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020721"><span class="hs-identifier hs-var hs-var">addFromToEdge</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo))
-&gt; LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapSingleton"><span class="hs-identifier hs-var">mapSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020725"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020724"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-377"></span><span>        </span><span class="annot"><a href="#local-6989586621681020721"><span class="hs-identifier hs-var">addFromToEdge</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020718"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020718"><span class="hs-identifier hs-var">wm</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo))
-&gt; LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; EdgeInfo -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020725"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020724"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020718"><span class="hs-identifier hs-var">wm</span></a></span><span>
</span><span id="line-378"></span><span>        </span><span class="hs-comment">-- We must add the destination node explicitly</span><span>
</span><span id="line-379"></span><span>        </span><span id="local-6989586621681020720"><span class="annot"><span class="annottext">addDestNode :: Maybe (map a) -&gt; Maybe (map a)
</span><a href="#local-6989586621681020720"><span class="hs-identifier hs-var hs-var">addDestNode</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe (map a)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">map a -&gt; Maybe (map a)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(map a -&gt; Maybe (map a)) -&gt; map a -&gt; Maybe (map a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">map a
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span>
</span><span id="line-380"></span><span>        </span><span class="annot"><a href="#local-6989586621681020720"><span class="hs-identifier hs-var">addDestNode</span></a></span><span> </span><span id="local-6989586621681020715"><span class="annot"><span class="annottext">n :: Maybe (map a)
</span><a href="#local-6989586621681020715"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">map a
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (map a)
</span><a href="#local-6989586621681020715"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-381"></span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="hs-comment">-- | Adds a edge with the given weight to the cfg</span><span>
</span><span id="line-384"></span><span class="hs-comment">--   If there already existed an edge it is overwritten.</span><span>
</span><span id="line-385"></span><span class="hs-comment">--   `addWeightEdge from to weight cfg`</span><span>
</span><span id="line-386"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addWeightEdge"><span class="hs-identifier hs-type">addWeightEdge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-387"></span><span id="addWeightEdge"><span class="annot"><span class="annottext">addWeightEdge :: Label -&gt; Label -&gt; EdgeWeight -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addWeightEdge"><span class="hs-identifier hs-var hs-var">addWeightEdge</span></a></span></span><span> </span><span id="local-6989586621681020714"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020714"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020713"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020713"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020712"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020712"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span id="local-6989586621681020711"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020711"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-388"></span><span>    </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020714"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020713"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#mkWeightInfo"><span class="hs-identifier hs-var">mkWeightInfo</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020712"><span class="hs-identifier hs-var">weight</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020711"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-389"></span><span>
</span><span id="line-390"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#delEdge"><span class="hs-identifier hs-type">delEdge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-391"></span><span id="delEdge"><span class="annot"><span class="annottext">delEdge :: Label -&gt; Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#delEdge"><span class="hs-identifier hs-var hs-var">delEdge</span></a></span></span><span> </span><span id="local-6989586621681020710"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020710"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020709"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020709"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020708"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020708"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-392"></span><span>    </span><span class="annot"><span class="annottext">(Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo))
-&gt; KeyOf LabelMap -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(Maybe a -&gt; Maybe a) -&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapAlter"><span class="hs-identifier hs-var">mapAlter</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020707"><span class="hs-identifier hs-var">remDest</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020710"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020708"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-393"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-394"></span><span>        </span><span id="local-6989586621681020707"><span class="annot"><span class="annottext">remDest :: Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020707"><span class="hs-identifier hs-var hs-var">remDest</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-395"></span><span>        </span><span class="annot"><a href="#local-6989586621681020707"><span class="hs-identifier hs-var">remDest</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020706"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020706"><span class="hs-identifier hs-var">wm</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo))
-&gt; LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapDelete"><span class="hs-identifier hs-var">mapDelete</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020709"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020706"><span class="hs-identifier hs-var">wm</span></a></span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span>
</span><span id="line-398"></span><span class="hs-comment">-- | Destinations from bid ordered by weight (descending)</span><span>
</span><span id="line-399"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccEdgesSorted"><span class="hs-identifier hs-type">getSuccEdgesSorted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-400"></span><span id="getSuccEdgesSorted"><span class="annot"><span class="annottext">getSuccEdgesSorted :: CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccEdgesSorted"><span class="hs-identifier hs-var hs-var">getSuccEdgesSorted</span></a></span></span><span> </span><span id="local-6989586621681020704"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020704"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020703"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020703"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-401"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020702"><span class="annot"><span class="annottext">destMap :: LabelMap EdgeInfo
</span><a href="#local-6989586621681020702"><span class="hs-identifier hs-var hs-var">destMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; KeyOf LabelMap -&gt; CFG -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; a -&gt; KeyOf map -&gt; map a -&gt; a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFindWithDefault"><span class="hs-identifier hs-var">mapFindWithDefault</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020703"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020704"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-402"></span><span>        </span><span id="local-6989586621681020700"><span class="annot"><span class="annottext">cfgEdges :: [(KeyOf LabelMap, EdgeInfo)]
</span><a href="#local-6989586621681020700"><span class="hs-identifier hs-var hs-var">cfgEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [(KeyOf LabelMap, EdgeInfo)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020702"><span class="hs-identifier hs-var">destMap</span></a></span><span>
</span><span id="line-403"></span><span>        </span><span id="local-6989586621681020699"><span class="annot"><span class="annottext">sortedEdges :: [(Label, EdgeInfo)]
</span><a href="#local-6989586621681020699"><span class="hs-identifier hs-var hs-var">sortedEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; EdgeWeight)
-&gt; [(Label, EdgeInfo)] -&gt; [(Label, EdgeInfo)]
forall b a. Ord b =&gt; (a -&gt; b) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Exts.html#sortWith"><span class="hs-identifier hs-var">sortWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#negate"><span class="hs-identifier hs-var">negate</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; EdgeWeight)
-&gt; ((Label, EdgeInfo) -&gt; EdgeWeight)
-&gt; (Label, EdgeInfo)
-&gt; EdgeWeight
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; EdgeWeight)
-&gt; ((Label, EdgeInfo) -&gt; EdgeInfo)
-&gt; (Label, EdgeInfo)
-&gt; EdgeWeight
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; EdgeInfo
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, EdgeInfo)]
[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020700"><span class="hs-identifier hs-var">cfgEdges</span></a></span><span>
</span><span id="line-404"></span><span>    </span><span class="hs-keyword">in</span><span>  </span><span class="hs-comment">--pprTrace &quot;getSuccEdgesSorted&quot; (ppr bid &lt;+&gt; text &quot;map:&quot; &lt;+&gt; ppr m)</span><span>
</span><span id="line-405"></span><span>        </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020699"><span class="hs-identifier hs-var">sortedEdges</span></a></span><span>
</span><span id="line-406"></span><span>
</span><span id="line-407"></span><span class="hs-comment">-- | Get successors of a given node with edge weights.</span><span>
</span><span id="line-408"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-type">getSuccessorEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-409"></span><span id="getSuccessorEdges"><span class="annot"><span class="annottext">getSuccessorEdges :: HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-var hs-var">getSuccessorEdges</span></a></span></span><span> </span><span id="local-6989586621681020691"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020691"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020690"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020690"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
-&gt; (LabelMap EdgeInfo -&gt; [(Label, EdgeInfo)])
-&gt; Maybe (LabelMap EdgeInfo)
-&gt; [(Label, EdgeInfo)]
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020689"><span class="hs-identifier hs-var">lookupError</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [(Label, EdgeInfo)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; CFG -&gt; Maybe (LabelMap EdgeInfo)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020690"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020691"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-411"></span><span>    </span><span id="local-6989586621681020689"><span class="annot"><span class="annottext">lookupError :: [(Label, EdgeInfo)]
</span><a href="#local-6989586621681020689"><span class="hs-identifier hs-var hs-var">lookupError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [(Label, EdgeInfo)]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getSuccessorEdges: Block does not exist&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; [(Label, EdgeInfo)]) -&gt; SDoc -&gt; [(Label, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-412"></span><span>                    </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020690"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; SDoc
</span><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-var">pprEdgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020691"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-413"></span><span>
</span><span id="line-414"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-type">getEdgeInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span>
</span><span id="line-415"></span><span id="getEdgeInfo"><span class="annot"><span class="annottext">getEdgeInfo :: Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var hs-var">getEdgeInfo</span></a></span></span><span> </span><span id="local-6989586621681020688"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020688"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020687"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020687"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020686"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020686"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-416"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020685"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020685"><span class="hs-identifier hs-var">wm</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; CFG -&gt; Maybe (LabelMap EdgeInfo)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020688"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020686"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-417"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020684"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020684"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; Maybe EdgeInfo
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020687"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020685"><span class="hs-identifier hs-var">wm</span></a></span><span>
</span><span id="line-418"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; Maybe EdgeInfo
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; Maybe EdgeInfo) -&gt; EdgeInfo -&gt; Maybe EdgeInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020684"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-419"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-420"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe EdgeInfo
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-421"></span><span>
</span><span id="line-422"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getEdgeWeight"><span class="hs-identifier hs-type">getEdgeWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-423"></span><span id="getEdgeWeight"><span class="annot"><span class="annottext">getEdgeWeight :: CFG -&gt; Label -&gt; Label -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeWeight"><span class="hs-identifier hs-var hs-var">getEdgeWeight</span></a></span></span><span> </span><span id="local-6989586621681020681"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020681"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020680"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020680"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020679"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020679"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-424"></span><span>    </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; EdgeWeight) -&gt; EdgeInfo -&gt; EdgeWeight
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe EdgeInfo -&gt; EdgeInfo
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Edgeweight for noexisting block&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe EdgeInfo -&gt; EdgeInfo) -&gt; Maybe EdgeInfo -&gt; EdgeInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-425"></span><span>                 </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020680"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020679"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020681"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getTransitionSource"><span class="hs-identifier hs-type">getTransitionSource</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TransitionSource"><span class="hs-identifier hs-type">TransitionSource</span></a></span><span>
</span><span id="line-428"></span><span id="getTransitionSource"><span class="annot"><span class="annottext">getTransitionSource :: Label -&gt; Label -&gt; CFG -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#getTransitionSource"><span class="hs-identifier hs-var hs-var">getTransitionSource</span></a></span></span><span> </span><span id="local-6989586621681020677"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020677"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020676"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020676"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020675"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020675"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; TransitionSource) -&gt; EdgeInfo -&gt; TransitionSource
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe EdgeInfo -&gt; EdgeInfo
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Source info for noexisting block&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe EdgeInfo -&gt; EdgeInfo) -&gt; Maybe EdgeInfo -&gt; EdgeInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-429"></span><span>                        </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020677"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020676"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020675"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-430"></span><span>
</span><span id="line-431"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#reverseEdges"><span class="hs-identifier hs-type">reverseEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-432"></span><span id="reverseEdges"><span class="annot"><span class="annottext">reverseEdges :: CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#reverseEdges"><span class="hs-identifier hs-var hs-var">reverseEdges</span></a></span></span><span> </span><span id="local-6989586621681020674"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020674"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; CFG)
-&gt; CFG -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020673"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020673"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020672"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681020672"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020671"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020671"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; LabelMap EdgeInfo -&gt; CFG
</span><a href="#local-6989586621681020670"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020669"><span class="hs-identifier hs-var">addNode</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020673"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020672"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020672"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020671"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020674"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-433"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-434"></span><span>    </span><span class="hs-comment">-- We must preserve nodes without outgoing edges!</span><span>
</span><span id="line-435"></span><span>    </span><span class="annot"><a href="#local-6989586621681020669"><span class="hs-identifier hs-type">addNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-436"></span><span>    </span><span id="local-6989586621681020669"><span class="annot"><span class="annottext">addNode :: CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020669"><span class="hs-identifier hs-var hs-var">addNode</span></a></span></span><span> </span><span id="local-6989586621681020668"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020668"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020667"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020667"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo)
-&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(a -&gt; a -&gt; a) -&gt; KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsertWith"><span class="hs-identifier hs-var">mapInsertWith</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapUnion"><span class="hs-identifier hs-var">mapUnion</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020667"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020668"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-437"></span><span>    </span><span class="annot"><a href="#local-6989586621681020670"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-438"></span><span>    </span><span id="local-6989586621681020670"><span class="annot"><span class="annottext">go :: CFG -&gt; Label -&gt; LabelMap EdgeInfo -&gt; CFG
</span><a href="#local-6989586621681020670"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681020664"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020664"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020663"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020663"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020662"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020662"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; KeyOf LabelMap -&gt; EdgeInfo -&gt; CFG)
-&gt; CFG -&gt; LabelMap EdgeInfo -&gt; CFG
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020661"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020661"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020660"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681020660"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020659"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020659"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020660"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020663"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020659"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020661"><span class="hs-identifier hs-var">cfg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020664"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020662"><span class="hs-identifier hs-var">toMap</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-comment">-- | Returns a unordered list of all edges with info</span><span>
</span><span id="line-442"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-type">infoEdgeList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-443"></span><span id="infoEdgeList"><span class="annot"><span class="annottext">infoEdgeList :: CFG -&gt; [CfgEdge]
</span><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-var hs-var">infoEdgeList</span></a></span></span><span> </span><span id="local-6989586621681020658"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020658"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-444"></span><span>    </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020657"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [(KeyOf LabelMap, LabelMap EdgeInfo)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020658"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-446"></span><span>    </span><span class="hs-comment">-- We avoid foldMap to avoid thunk buildup</span><span>
</span><span id="line-447"></span><span>    </span><span class="annot"><a href="#local-6989586621681020657"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-448"></span><span>    </span><span id="local-6989586621681020657"><span class="annot"><span class="annottext">go :: [(Label, LabelMap EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020657"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681020656"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020656"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020656"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-449"></span><span>    </span><span class="annot"><a href="#local-6989586621681020657"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681020655"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020655"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020654"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020654"><span class="hs-identifier hs-var">toMap</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681020653"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020653"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020652"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020652"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-450"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [(Label, EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020651"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020653"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020655"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [(KeyOf LabelMap, EdgeInfo)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020654"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020652"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-451"></span><span>    </span><span class="annot"><a href="#local-6989586621681020651"><span class="hs-identifier hs-type">go'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-452"></span><span>    </span><span id="local-6989586621681020651"><span class="annot"><span class="annottext">go' :: [(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [(Label, EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020651"><span class="hs-identifier hs-var hs-var">go'</span></a></span></span><span> </span><span id="local-6989586621681020650"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020650"><span class="hs-identifier hs-var">froms</span></a></span></span><span> </span><span class="annot"><span class="annottext">Label
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span>              </span><span id="local-6989586621681020649"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020649"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020657"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020650"><span class="hs-identifier hs-var">froms</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020649"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-453"></span><span>    </span><span class="annot"><a href="#local-6989586621681020651"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span id="local-6989586621681020648"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020648"><span class="hs-identifier hs-var">froms</span></a></span></span><span> </span><span id="local-6989586621681020647"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020647"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681020646"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020646"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020645"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020645"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681020644"><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020644"><span class="hs-identifier hs-var">tos</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020643"><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020643"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-454"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [(Label, EdgeInfo)] -&gt; [CfgEdge] -&gt; [CfgEdge]
</span><a href="#local-6989586621681020651"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020648"><span class="hs-identifier hs-var">froms</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020647"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020644"><span class="hs-identifier hs-var">tos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CfgEdge
</span><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-var">CfgEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020647"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020646"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020645"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020643"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-455"></span><span>
</span><span id="line-456"></span><span class="hs-comment">-- | Returns a unordered list of all edges without weights</span><span>
</span><span id="line-457"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#edgeList"><span class="hs-identifier hs-type">edgeList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-458"></span><span id="edgeList"><span class="annot"><span class="annottext">edgeList :: CFG -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#edgeList"><span class="hs-identifier hs-var hs-var">edgeList</span></a></span></span><span> </span><span id="local-6989586621681020642"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020642"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-459"></span><span>    </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020641"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [(KeyOf LabelMap, LabelMap EdgeInfo)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020642"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-460"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-461"></span><span>    </span><span class="hs-comment">-- We avoid foldMap to avoid thunk buildup</span><span>
</span><span id="line-462"></span><span>    </span><span class="annot"><a href="#local-6989586621681020641"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-463"></span><span>    </span><span id="local-6989586621681020641"><span class="annot"><span class="annottext">go :: [(Label, LabelMap EdgeInfo)] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020641"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681020640"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020640"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020640"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-464"></span><span>    </span><span class="annot"><a href="#local-6989586621681020641"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681020639"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020639"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020638"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020638"><span class="hs-identifier hs-var">toMap</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681020637"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020637"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020636"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020636"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-465"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [Label] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020635"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020637"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020639"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020638"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020636"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-466"></span><span>    </span><span class="annot"><a href="#local-6989586621681020635"><span class="hs-identifier hs-type">go'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-467"></span><span>    </span><span id="local-6989586621681020635"><span class="annot"><span class="annottext">go' :: [(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [Label] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020635"><span class="hs-identifier hs-var hs-var">go'</span></a></span></span><span> </span><span id="local-6989586621681020634"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020634"><span class="hs-identifier hs-var">froms</span></a></span></span><span> </span><span class="annot"><span class="annottext">Label
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span>              </span><span id="local-6989586621681020633"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020633"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020641"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020634"><span class="hs-identifier hs-var">froms</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020633"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-468"></span><span>    </span><span class="annot"><a href="#local-6989586621681020635"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span id="local-6989586621681020632"><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020632"><span class="hs-identifier hs-var">froms</span></a></span></span><span> </span><span id="local-6989586621681020631"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020631"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020630"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020630"><span class="hs-identifier hs-var">to</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681020629"><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020629"><span class="hs-identifier hs-var">tos</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020628"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020628"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-469"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
-&gt; Label -&gt; [Label] -&gt; [Edge] -&gt; [Edge]
</span><a href="#local-6989586621681020635"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelMap EdgeInfo)]
</span><a href="#local-6989586621681020632"><span class="hs-identifier hs-var">froms</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020631"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020629"><span class="hs-identifier hs-var">tos</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020631"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020630"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Edge -&gt; [Edge] -&gt; [Edge]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020628"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span class="hs-comment">-- | Get successors of a given node without edge weights.</span><span>
</span><span id="line-472"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-type">getSuccessors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-473"></span><span id="getSuccessors"><span class="annot"><span class="annottext">getSuccessors :: HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-var hs-var">getSuccessors</span></a></span></span><span> </span><span id="local-6989586621681020621"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020621"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020620"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020620"><span class="hs-identifier hs-var">bid</span></a></span></span><span>
</span><span id="line-474"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020619"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020619"><span class="hs-identifier hs-var">wm</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; CFG -&gt; Maybe (LabelMap EdgeInfo)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020620"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020621"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-475"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020619"><span class="hs-identifier hs-var">wm</span></a></span><span>
</span><span id="line-476"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020618"><span class="hs-identifier hs-var">lookupError</span></a></span><span>
</span><span id="line-477"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-478"></span><span>      </span><span id="local-6989586621681020618"><span class="annot"><span class="annottext">lookupError :: [Label]
</span><a href="#local-6989586621681020618"><span class="hs-identifier hs-var hs-var">lookupError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [Label]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getSuccessors: Block does not exist&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; [Label]) -&gt; SDoc -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-479"></span><span>                    </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020620"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; SDoc
</span><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-var">pprEdgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020621"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-480"></span><span>
</span><span id="line-481"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-type">pprEdgeWeights</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-482"></span><span id="pprEdgeWeights"><span class="annot"><span class="annottext">pprEdgeWeights :: CFG -&gt; SDoc
</span><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-var hs-var">pprEdgeWeights</span></a></span></span><span> </span><span id="local-6989586621681020617"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020617"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-483"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020616"><span class="annot"><span class="annottext">edges :: [CfgEdge]
</span><a href="#local-6989586621681020616"><span class="hs-identifier hs-var hs-var">edges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CfgEdge] -&gt; [CfgEdge]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">([CfgEdge] -&gt; [CfgEdge]) -&gt; [CfgEdge] -&gt; [CfgEdge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [CfgEdge]
</span><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-var">infoEdgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020617"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-484"></span><span>        </span><span id="local-6989586621681020611"><span class="annot"><span class="annottext">printEdge :: CfgEdge -&gt; SDoc
</span><a href="#local-6989586621681020611"><span class="hs-identifier hs-var hs-var">printEdge</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020610"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020610"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020609"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020609"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">edgeWeight :: EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020608"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020608"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-485"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020610"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020609"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-486"></span><span>              </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;[label=\&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020608"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;,weight=\&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-487"></span><span>              </span><span class="annot"><span class="annottext">EdgeWeight -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020608"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;];\n&quot;</span></span><span>
</span><span id="line-488"></span><span>        </span><span class="hs-comment">--for the case that there are no edges from/to this node.</span><span>
</span><span id="line-489"></span><span>        </span><span class="hs-comment">--This should rarely happen but it can save a lot of time</span><span>
</span><span id="line-490"></span><span>        </span><span class="hs-comment">--to immediately see it when it does.</span><span>
</span><span id="line-491"></span><span>        </span><span id="local-6989586621681020605"><span class="annot"><span class="annottext">printNode :: a -&gt; SDoc
</span><a href="#local-6989586621681020605"><span class="hs-identifier hs-var hs-var">printNode</span></a></span></span><span> </span><span id="local-6989586621681020604"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020604"><span class="hs-identifier hs-var">node</span></a></span></span><span>
</span><span id="line-492"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020604"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;;\n&quot;</span></span><span>
</span><span id="line-493"></span><span>        </span><span id="local-6989586621681020603"><span class="annot"><span class="annottext">getEdgeNodes :: CfgEdge -&gt; [Label]
</span><a href="#local-6989586621681020603"><span class="hs-identifier hs-var hs-var">getEdgeNodes</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020602"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020602"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020601"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020601"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020602"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020601"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-494"></span><span>        </span><span id="local-6989586621681020600"><span class="annot"><span class="annottext">edgeNodes :: LabelSet
</span><a href="#local-6989586621681020600"><span class="hs-identifier hs-var hs-var">edgeNodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([ElemOf LabelSet] -&gt; LabelSet) -&gt; [ElemOf LabelSet] -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(CfgEdge -&gt; [Label]) -&gt; [CfgEdge] -&gt; [Label]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; [Label]
</span><a href="#local-6989586621681020603"><span class="hs-identifier hs-var">getEdgeNodes</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020616"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-495"></span><span>        </span><span id="local-6989586621681020599"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020599"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Bool) -&gt; [Label] -&gt; [Label]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020598"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020598"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (LabelSet -&gt; Bool) -&gt; LabelSet -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020598"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020600"><span class="hs-identifier hs-var">edgeNodes</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [Label]) -&gt; (CFG -&gt; [Label]) -&gt; CFG -&gt; [Label]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; [Label]) -&gt; CFG -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Bool) -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(a -&gt; Bool) -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFilter"><span class="hs-identifier hs-var">mapFilter</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020617"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-496"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-497"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;digraph {\n&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-498"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc -&gt; SDoc) -&gt; SDoc -&gt; [SDoc] -&gt; SDoc
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">(&lt;&gt;)</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CfgEdge -&gt; SDoc) -&gt; [CfgEdge] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CfgEdge -&gt; SDoc
</span><a href="#local-6989586621681020611"><span class="hs-identifier hs-var">printEdge</span></a></span><span> </span><span class="annot"><span class="annottext">[CfgEdge]
</span><a href="#local-6989586621681020616"><span class="hs-identifier hs-var">edges</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-499"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc -&gt; SDoc) -&gt; SDoc -&gt; [SDoc] -&gt; SDoc
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">(&lt;&gt;)</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Label -&gt; SDoc) -&gt; [Label] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="#local-6989586621681020605"><span class="hs-identifier hs-var">printNode</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020599"><span class="hs-identifier hs-var">nodes</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-500"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;}\n&quot;</span></span><span>
</span><span id="line-501"></span><span>
</span><span id="line-502"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#updateEdgeWeight"><span class="hs-pragma hs-type">updateEdgeWeight</span></a></span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-comment">--Allows eliminating the tuple when possible</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- | Invariant: The edge **must** exist already in the graph.</span><span>
</span><span id="line-504"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#updateEdgeWeight"><span class="hs-identifier hs-type">updateEdgeWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-505"></span><span id="updateEdgeWeight"><span class="annot"><span class="annottext">updateEdgeWeight :: (EdgeWeight -&gt; EdgeWeight) -&gt; Edge -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#updateEdgeWeight"><span class="hs-identifier hs-var hs-var">updateEdgeWeight</span></a></span></span><span> </span><span id="local-6989586621681020593"><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020593"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020592"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020592"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020591"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020591"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020590"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020590"><span class="hs-identifier hs-var">cfg</span></a></span></span><span>
</span><span id="line-506"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020589"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020589"><span class="hs-identifier hs-var">oldInfo</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020592"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020591"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020590"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-507"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020588"><span class="annot"><span class="annottext">oldWeight :: EdgeWeight
</span><a href="#local-6989586621681020588"><span class="hs-identifier hs-var hs-var">oldWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020589"><span class="hs-identifier hs-var">oldInfo</span></a></span><span>
</span><span id="line-508"></span><span>          </span><span class="hs-glyph">!</span><span id="local-6989586621681020587"><span class="annot"><span class="annottext">newWeight :: EdgeWeight
</span><a href="#local-6989586621681020587"><span class="hs-identifier hs-var hs-var">newWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020593"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020588"><span class="hs-identifier hs-var">oldWeight</span></a></span><span>
</span><span id="line-509"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020592"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020591"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020589"><span class="hs-identifier hs-var">oldInfo</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020587"><span class="hs-identifier hs-var">newWeight</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020590"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-510"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-511"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CFG
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Trying to update invalid edge&quot;</span></span><span>
</span><span id="line-512"></span><span>
</span><span id="line-513"></span><span class="hs-comment">-- from to oldWeight =&gt; newWeight</span><span>
</span><span id="line-514"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mapWeights"><span class="hs-identifier hs-type">mapWeights</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-515"></span><span id="mapWeights"><span class="annot"><span class="annottext">mapWeights :: (Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight) -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#mapWeights"><span class="hs-identifier hs-var hs-var">mapWeights</span></a></span></span><span> </span><span id="local-6989586621681020584"><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020584"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681020583"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020583"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-516"></span><span>  </span><span class="annot"><span class="annottext">(CFG -&gt; CfgEdge -&gt; CFG) -&gt; CFG -&gt; [CfgEdge] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020582"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020582"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CfgEdge"><span class="hs-identifier hs-type">CfgEdge</span></a></span><span> </span><span id="local-6989586621681020581"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020581"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020580"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020580"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020579"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020579"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-517"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020578"><span class="annot"><span class="annottext">oldWeight :: EdgeWeight
</span><a href="#local-6989586621681020578"><span class="hs-identifier hs-var hs-var">oldWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020579"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-518"></span><span>                </span><span id="local-6989586621681020577"><span class="annot"><span class="annottext">newWeight :: EdgeWeight
</span><a href="#local-6989586621681020577"><span class="hs-identifier hs-var hs-var">newWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020584"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020581"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020580"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020578"><span class="hs-identifier hs-var">oldWeight</span></a></span><span>
</span><span id="line-519"></span><span>            </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020581"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020580"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020579"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">edgeWeight :: EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var">edgeWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020577"><span class="hs-identifier hs-var">newWeight</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020582"><span class="hs-identifier hs-var">cfg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>          </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020583"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [CfgEdge]
</span><a href="GHC.CmmToAsm.CFG.html#infoEdgeList"><span class="hs-identifier hs-var">infoEdgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020583"><span class="hs-identifier hs-var">cfg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span>
</span><span id="line-522"></span><span>
</span><span id="line-523"></span><span class="hs-comment">-- | Insert a block in the control flow between two other blocks.</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- We pass a list of tuples (A,B,C) where</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- * A -&gt; C: Old edge</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- * A -&gt; B -&gt; C : New Arc, where B is the new block.</span><span>
</span><span id="line-527"></span><span class="hs-comment">-- It's possible that a block has two jumps to the same block</span><span>
</span><span id="line-528"></span><span class="hs-comment">-- in the assembly code. However we still only store a single edge for</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- these cases.</span><span>
</span><span id="line-530"></span><span class="hs-comment">-- We assign the old edge info to the edge A -&gt; B and assign B -&gt; C the</span><span>
</span><span id="line-531"></span><span class="hs-comment">-- weight of an unconditional jump.</span><span>
</span><span id="line-532"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#addNodesBetween"><span class="hs-identifier hs-type">addNodesBetween</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">D.DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-533"></span><span id="addNodesBetween"><span class="annot"><span class="annottext">addNodesBetween :: DynFlags -&gt; CFG -&gt; [(Label, Label, Label)] -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addNodesBetween"><span class="hs-identifier hs-var hs-var">addNodesBetween</span></a></span></span><span> </span><span id="local-6989586621681020576"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681020576"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681020575"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020575"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020574"><span class="annot"><span class="annottext">[(Label, Label, Label)]
</span><a href="#local-6989586621681020574"><span class="hs-identifier hs-var">updates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-534"></span><span>  </span><span class="annot"><span class="annottext">(CFG -&gt; (Label, Label, Label, EdgeInfo) -&gt; CFG)
-&gt; CFG -&gt; [(Label, Label, Label, EdgeInfo)] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span>  </span><span class="annot"><span class="annottext">CFG -&gt; (Label, Label, Label, EdgeInfo) -&gt; CFG
</span><a href="#local-6989586621681020573"><span class="hs-identifier hs-var">updateWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020575"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">([(Label, Label, Label, EdgeInfo)] -&gt; CFG)
-&gt; ([(Label, Label, Label)] -&gt; [(Label, Label, Label, EdgeInfo)])
-&gt; [(Label, Label, Label)]
-&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-535"></span><span>          </span><span class="annot"><span class="annottext">[(Label, Label, Label)] -&gt; [(Label, Label, Label, EdgeInfo)]
</span><a href="#local-6989586621681020572"><span class="hs-identifier hs-var">weightUpdates</span></a></span><span> </span><span class="annot"><span class="annottext">([(Label, Label, Label)] -&gt; CFG) -&gt; [(Label, Label, Label)] -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, Label, Label)]
</span><a href="#local-6989586621681020574"><span class="hs-identifier hs-var">updates</span></a></span><span>
</span><span id="line-536"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-537"></span><span>      </span><span id="local-6989586621681020571"><span class="annot"><span class="annottext">weight :: EdgeWeight
</span><a href="#local-6989586621681020571"><span class="hs-identifier hs-var hs-var">weight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; EdgeWeight) -&gt; (DynFlags -&gt; Int) -&gt; DynFlags -&gt; EdgeWeight
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#uncondWeight"><span class="hs-identifier hs-var hs-var">D.uncondWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(CfgWeights -&gt; Int) -&gt; (DynFlags -&gt; CfgWeights) -&gt; DynFlags -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-538"></span><span>                </span><span class="annot"><span class="annottext">DynFlags -&gt; CfgWeights
</span><a href="GHC.Driver.Session.html#cfgWeightInfo"><span class="hs-identifier hs-var hs-var">D.cfgWeightInfo</span></a></span><span> </span><span class="annot"><span class="annottext">(DynFlags -&gt; EdgeWeight) -&gt; DynFlags -&gt; EdgeWeight
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681020576"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-539"></span><span>      </span><span class="hs-comment">-- We might add two blocks for different jumps along a single</span><span>
</span><span id="line-540"></span><span>      </span><span class="hs-comment">-- edge. So we end up with edges:   A -&gt; B -&gt; C   ,   A -&gt; D -&gt; C</span><span>
</span><span id="line-541"></span><span>      </span><span class="hs-comment">-- in this case after applying the first update the weight for A -&gt; C</span><span>
</span><span id="line-542"></span><span>      </span><span class="hs-comment">-- is no longer available. So we calculate future weights before updates.</span><span>
</span><span id="line-543"></span><span>      </span><span id="local-6989586621681020572"><span class="annot"><span class="annottext">weightUpdates :: [(Label, Label, Label)] -&gt; [(Label, Label, Label, EdgeInfo)]
</span><a href="#local-6989586621681020572"><span class="hs-identifier hs-var hs-var">weightUpdates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Label, Label, Label) -&gt; (Label, Label, Label, EdgeInfo))
-&gt; [(Label, Label, Label)] -&gt; [(Label, Label, Label, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, Label, Label) -&gt; (Label, Label, Label, EdgeInfo)
</span><a href="#local-6989586621681020570"><span class="hs-identifier hs-var">getWeight</span></a></span><span>
</span><span id="line-544"></span><span>      </span><span class="annot"><a href="#local-6989586621681020570"><span class="hs-identifier hs-type">getWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span>      </span><span id="local-6989586621681020570"><span class="annot"><span class="annottext">getWeight :: (Label, Label, Label) -&gt; (Label, Label, Label, EdgeInfo)
</span><a href="#local-6989586621681020570"><span class="hs-identifier hs-var hs-var">getWeight</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020569"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020569"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020568"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020568"><span class="hs-identifier hs-var">between</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020567"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020567"><span class="hs-identifier hs-var">old</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-546"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020566"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020566"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; Maybe EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeInfo"><span class="hs-identifier hs-var">getEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020569"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020567"><span class="hs-identifier hs-var">old</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020575"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-547"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020569"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020568"><span class="hs-identifier hs-var">between</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020567"><span class="hs-identifier hs-var">old</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020566"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-549"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; (Label, Label, Label, EdgeInfo)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Can't find weight for edge that should have one&quot;</span></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-550"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;triple&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, Label, Label) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020569"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020568"><span class="hs-identifier hs-var">between</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020567"><span class="hs-identifier hs-var">old</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-551"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;updates&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, Label, Label)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, Label, Label)]
</span><a href="#local-6989586621681020574"><span class="hs-identifier hs-var">updates</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-552"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cfg:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; SDoc
</span><a href="GHC.CmmToAsm.CFG.html#pprEdgeWeights"><span class="hs-identifier hs-var">pprEdgeWeights</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020575"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-553"></span><span>      </span><span class="annot"><a href="#local-6989586621681020573"><span class="hs-identifier hs-type">updateWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-554"></span><span>      </span><span id="local-6989586621681020573"><span class="annot"><span class="annottext">updateWeight :: CFG -&gt; (Label, Label, Label, EdgeInfo) -&gt; CFG
</span><a href="#local-6989586621681020573"><span class="hs-identifier hs-var hs-var">updateWeight</span></a></span></span><span> </span><span id="local-6989586621681020565"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020565"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020564"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020564"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020563"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020563"><span class="hs-identifier hs-var">between</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020562"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020562"><span class="hs-identifier hs-var">old</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020561"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020561"><span class="hs-identifier hs-var">edgeInfo</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-555"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addEdge"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020564"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020563"><span class="hs-identifier hs-var">between</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020561"><span class="hs-identifier hs-var">edgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-556"></span><span>          </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeWeight -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#addWeightEdge"><span class="hs-identifier hs-var">addWeightEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020563"><span class="hs-identifier hs-var">between</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020562"><span class="hs-identifier hs-var">old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020571"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-557"></span><span>          </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#delEdge"><span class="hs-identifier hs-var">delEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020564"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020562"><span class="hs-identifier hs-var">old</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020565"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-558"></span><span>
</span><span id="line-559"></span><span class="hs-comment">{-
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~       Note [CFG Edge Weights]    ~~~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  Edge weights assigned do not currently represent a specific
  cost model and rather just a ranking of which blocks should
  be placed next to each other given their connection type in
  the CFG.
  This is especially relevant if we whenever two blocks will
  jump to the same target.

                     A   B
                      \ /
                       C

  Should A or B be placed in front of C? The block layout algorithm
  decides this based on which edge (A,C)/(B,C) is heavier. So we
  make a educated guess on which branch should be preferred.

  We rank edges in this order:
  * Unconditional Control Transfer - They will always
    transfer control to their target. Unless there is a info table
    we can turn the jump into a fallthrough as well.
    We use 20k as default, so it's easy to spot if values have been
    modified but unlikely that we run into issues with overflow.
  * If branches (likely) - We assume branches marked as likely
    are taken more than 80% of the time.
    By ranking them below unconditional jumps we make sure we
    prefer the unconditional if there is a conditional and
    unconditional edge towards a block.
  * If branches (regular) - The false branch can potentially be turned
    into a fallthrough so we prefer it slightly over the true branch.
  * Unlikely branches - These can be assumed to be taken less than 20%
    of the time. So we given them one of the lowest priorities.
  * Switches - Switches at this level are implemented as jump tables
    so have a larger number of successors. So without more information
    we can only say that each individual successor is unlikely to be
    jumped to and we rank them accordingly.
  * Calls - We currently ignore calls completely:
        * By the time we return from a call there is a good chance
          that the address we return to has already been evicted from
          cache eliminating a main advantage sequential placement brings.
        * Calls always require a info table in front of their return
          address. This reduces the chance that we return to the same
          cache line further.

-}</span><span>
</span><span id="line-607"></span><span class="hs-comment">-- | Generate weights for a Cmm proc based on some simple heuristics.</span><span>
</span><span id="line-608"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfgProc"><span class="hs-identifier hs-type">getCfgProc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CfgWeights"><span class="hs-identifier hs-type">D.CfgWeights</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#RawCmmDecl"><span class="hs-identifier hs-type">RawCmmDecl</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-609"></span><span id="getCfgProc"><span class="annot"><span class="annottext">getCfgProc :: CfgWeights -&gt; RawCmmDecl -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#getCfgProc"><span class="hs-identifier hs-var hs-var">getCfgProc</span></a></span></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span>
</span><span id="line-610"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfgProc"><span class="hs-identifier hs-var">getCfgProc</span></a></span><span> </span><span id="local-6989586621681020559"><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020559"><span class="hs-identifier hs-var">weights</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681020557"><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681020557"><span class="hs-identifier hs-var">_info</span></a></span></span><span> </span><span id="local-6989586621681020556"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681020556"><span class="hs-identifier hs-var">_lab</span></a></span></span><span> </span><span id="local-6989586621681020555"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681020555"><span class="hs-identifier hs-var">_live</span></a></span></span><span> </span><span id="local-6989586621681020554"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020554"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgWeights -&gt; CmmGraph -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#getCfg"><span class="hs-identifier hs-var">getCfg</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020559"><span class="hs-identifier hs-var">weights</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020554"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-611"></span><span>
</span><span id="line-612"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#getCfg"><span class="hs-identifier hs-type">getCfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CfgWeights"><span class="hs-identifier hs-type">D.CfgWeights</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmGraph"><span class="hs-identifier hs-type">CmmGraph</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-613"></span><span id="getCfg"><span class="annot"><span class="annottext">getCfg :: CfgWeights -&gt; CmmGraph -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#getCfg"><span class="hs-identifier hs-var hs-var">getCfg</span></a></span></span><span> </span><span id="local-6989586621681020553"><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020553"><span class="hs-identifier hs-var">weights</span></a></span></span><span> </span><span id="local-6989586621681020552"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020552"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-614"></span><span>  </span><span class="annot"><span class="annottext">(CFG -&gt; (Edge, EdgeInfo) -&gt; CFG)
-&gt; CFG -&gt; [(Edge, EdgeInfo)] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; (Edge, EdgeInfo) -&gt; CFG
</span><a href="#local-6989586621681020551"><span class="hs-identifier hs-var">insertEdge</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020550"><span class="hs-identifier hs-var">edgelessCfg</span></a></span><span> </span><span class="annot"><span class="annottext">([(Edge, EdgeInfo)] -&gt; CFG) -&gt; [(Edge, EdgeInfo)] -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmBlock -&gt; [(Edge, EdgeInfo)])
-&gt; [CmmBlock] -&gt; [(Edge, EdgeInfo)]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; [(Edge, EdgeInfo)]
</span><a href="#local-6989586621681020549"><span class="hs-identifier hs-var">getBlockEdges</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681020548"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-615"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-616"></span><span>    </span><span class="annot"><a href="GHC.Driver.Session.html#CFGWeights"><span class="hs-identifier hs-type">D.CFGWeights</span></a></span><span>
</span><span id="line-617"></span><span>            </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uncondWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#uncondWeight"><span class="hs-identifier hs-var">D.uncondWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020546"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020546"><span class="hs-identifier hs-var">uncondWeight</span></a></span></span><span>
</span><span id="line-618"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">condBranchWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#condBranchWeight"><span class="hs-identifier hs-var">D.condBranchWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020544"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020544"><span class="hs-identifier hs-var">condBranchWeight</span></a></span></span><span>
</span><span id="line-619"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">switchWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#switchWeight"><span class="hs-identifier hs-var">D.switchWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020542"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020542"><span class="hs-identifier hs-var">switchWeight</span></a></span></span><span>
</span><span id="line-620"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">callWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#callWeight"><span class="hs-identifier hs-var">D.callWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020540"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020540"><span class="hs-identifier hs-var">callWeight</span></a></span></span><span>
</span><span id="line-621"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">likelyCondWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#likelyCondWeight"><span class="hs-identifier hs-var">D.likelyCondWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020538"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020538"><span class="hs-identifier hs-var">likelyCondWeight</span></a></span></span><span>
</span><span id="line-622"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">unlikelyCondWeight :: CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#unlikelyCondWeight"><span class="hs-identifier hs-var">D.unlikelyCondWeight</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020536"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020536"><span class="hs-identifier hs-var">unlikelyCondWeight</span></a></span></span><span>
</span><span id="line-623"></span><span>            </span><span class="hs-comment">--  Last two are used in other places</span><span>
</span><span id="line-624"></span><span>            </span><span class="hs-comment">--, D.infoTablePenalty = infoTablePenalty</span><span>
</span><span id="line-625"></span><span>            </span><span class="hs-comment">--, D.backEdgeBonus = backEdgeBonus</span><span>
</span><span id="line-626"></span><span>            </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020553"><span class="hs-identifier hs-var">weights</span></a></span><span>
</span><span id="line-627"></span><span>    </span><span class="hs-comment">-- Explicitly add all nodes to the cfg to ensure they are part of the</span><span>
</span><span id="line-628"></span><span>    </span><span class="hs-comment">-- CFG.</span><span>
</span><span id="line-629"></span><span>    </span><span id="local-6989586621681020550"><span class="annot"><span class="annottext">edgelessCfg :: CFG
</span><a href="#local-6989586621681020550"><span class="hs-identifier hs-var hs-var">edgelessCfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, LabelMap EdgeInfo)] -&gt; CFG
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, LabelMap EdgeInfo)] -&gt; CFG)
-&gt; [(KeyOf LabelMap, LabelMap EdgeInfo)] -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [LabelMap EdgeInfo] -&gt; [(Label, LabelMap EdgeInfo)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CmmBlock -&gt; Label) -&gt; [CmmBlock] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; Label
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
NonLocal thing =&gt;
thing C x -&gt; Label
</span><a href="GHC.Cmm.Dataflow.Graph.html#entryLabel"><span class="hs-identifier hs-var">G.entryLabel</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681020548"><span class="hs-identifier hs-var">blocks</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [LabelMap EdgeInfo]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-630"></span><span>    </span><span class="annot"><a href="#local-6989586621681020551"><span class="hs-identifier hs-type">insertEdge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-631"></span><span>    </span><span id="local-6989586621681020551"><span class="annot"><span class="annottext">insertEdge :: CFG -&gt; (Edge, EdgeInfo) -&gt; CFG
</span><a href="#local-6989586621681020551"><span class="hs-identifier hs-var hs-var">insertEdge</span></a></span></span><span> </span><span id="local-6989586621681020533"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020533"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681020532"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020532"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020531"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020531"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span id="local-6989586621681020530"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020530"><span class="hs-identifier hs-var">weight</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-632"></span><span>      </span><span class="annot"><span class="annottext">(Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo))
-&gt; KeyOf LabelMap -&gt; CFG -&gt; CFG
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(Maybe a -&gt; Maybe a) -&gt; KeyOf map -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapAlter"><span class="hs-identifier hs-var">mapAlter</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020529"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020532"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020533"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-633"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-634"></span><span>          </span><span class="annot"><a href="#local-6989586621681020529"><span class="hs-identifier hs-type">f</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-635"></span><span>          </span><span id="local-6989586621681020529"><span class="annot"><span class="annottext">f :: Maybe (LabelMap EdgeInfo) -&gt; Maybe (LabelMap EdgeInfo)
</span><a href="#local-6989586621681020529"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap EdgeInfo)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo))
-&gt; LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapSingleton"><span class="hs-identifier hs-var">mapSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020531"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020530"><span class="hs-identifier hs-var">weight</span></a></span><span>
</span><span id="line-636"></span><span>          </span><span class="annot"><a href="#local-6989586621681020529"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020528"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020528"><span class="hs-identifier hs-var">destMap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo))
-&gt; LabelMap EdgeInfo -&gt; Maybe (LabelMap EdgeInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; EdgeInfo -&gt; LabelMap EdgeInfo -&gt; LabelMap EdgeInfo
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020531"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020530"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020528"><span class="hs-identifier hs-var">destMap</span></a></span><span>
</span><span id="line-637"></span><span>    </span><span class="annot"><a href="#local-6989586621681020549"><span class="hs-identifier hs-type">getBlockEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-638"></span><span>    </span><span id="local-6989586621681020549"><span class="annot"><span class="annottext">getBlockEdges :: CmmBlock -&gt; [(Edge, EdgeInfo)]
</span><a href="#local-6989586621681020549"><span class="hs-identifier hs-var hs-var">getBlockEdges</span></a></span></span><span> </span><span id="local-6989586621681020527"><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681020527"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-639"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020526"><span class="hs-identifier hs-var">branch</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-640"></span><span>        </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmBranch"><span class="hs-identifier hs-type">CmmBranch</span></a></span><span> </span><span id="local-6989586621681020522"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020522"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020521"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020522"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020546"><span class="hs-identifier hs-var">uncondWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-641"></span><span>        </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-type">CmmCondBranch</span></a></span><span> </span><span id="local-6989586621681020499"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020499"><span class="hs-identifier hs-var">cond</span></a></span></span><span> </span><span id="local-6989586621681020498"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020498"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621681020497"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020497"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681020496"><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020496"><span class="hs-identifier hs-var">l</span></a></span></span><span>
</span><span id="line-642"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020496"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-643"></span><span>              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020497"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020544"><span class="hs-identifier hs-var">condBranchWeight</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020498"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020544"><span class="hs-identifier hs-var">condBranchWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-644"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020496"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-645"></span><span>              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020497"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020536"><span class="hs-identifier hs-var">unlikelyCondWeight</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020498"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020538"><span class="hs-identifier hs-var">likelyCondWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-646"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020496"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-647"></span><span>              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020497"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020538"><span class="hs-identifier hs-var">likelyCondWeight</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020498"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020536"><span class="hs-identifier hs-var">unlikelyCondWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-648"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-649"></span><span>            </span><span id="local-6989586621681020494"><span class="annot"><span class="annottext">mkEdgeInfo :: Int -&gt; EdgeInfo
</span><a href="#local-6989586621681020494"><span class="hs-identifier hs-var hs-var">mkEdgeInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;Info&quot; (ppr branchInfo &lt;+&gt; ppr cond)</span><span>
</span><span id="line-650"></span><span>                         </span><span class="annot"><span class="annottext">TransitionSource -&gt; EdgeWeight -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-var">EdgeInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmNode O C -&gt; BranchInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-var">CmmSource</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020526"><span class="hs-identifier hs-var">branch</span></a></span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="#local-6989586621681020493"><span class="hs-identifier hs-var">branchInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; EdgeInfo) -&gt; (Int -&gt; EdgeWeight) -&gt; Int -&gt; EdgeInfo
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-651"></span><span>            </span><span id="local-6989586621681020495"><span class="annot"><span class="annottext">mkEdge :: Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020495"><span class="hs-identifier hs-var hs-var">mkEdge</span></a></span></span><span> </span><span id="local-6989586621681020492"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020492"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621681020491"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020491"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020490"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020492"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeInfo
</span><a href="#local-6989586621681020494"><span class="hs-identifier hs-var">mkEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020491"><span class="hs-identifier hs-var">weight</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-652"></span><span>            </span><span id="local-6989586621681020493"><span class="annot"><span class="annottext">branchInfo :: BranchInfo
</span><a href="#local-6989586621681020493"><span class="hs-identifier hs-var hs-var">branchInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-653"></span><span>              </span><span class="annot"><span class="annottext">DynFlags
-&gt; (BranchInfo -&gt; GlobalReg -&gt; BranchInfo)
-&gt; BranchInfo
-&gt; CmmExpr
-&gt; BranchInfo
forall r a b.
UserOfRegs r a =&gt;
DynFlags -&gt; (b -&gt; r -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldRegsUsed"><span class="hs-identifier hs-var">foldRegsUsed</span></a></span><span>
</span><span id="line-654"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; DynFlags
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;foldRegsDynFlags&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-655"></span><span>                </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020488"><span class="annot"><span class="annottext">BranchInfo
</span><a href="#local-6989586621681020488"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681020487"><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681020487"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681020487"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg -&gt; GlobalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#SpLim"><span class="hs-identifier hs-var">SpLim</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681020487"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg -&gt; GlobalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#HpLim"><span class="hs-identifier hs-var">HpLim</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681020487"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg -&gt; GlobalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#BaseReg"><span class="hs-identifier hs-var">BaseReg</span></a></span><span>
</span><span id="line-656"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#HeapStackCheck"><span class="hs-identifier hs-var">HeapStackCheck</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="#local-6989586621681020488"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-657"></span><span>                </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#NoInfo"><span class="hs-identifier hs-var">NoInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020499"><span class="hs-identifier hs-var">cond</span></a></span><span>
</span><span id="line-658"></span><span>
</span><span id="line-659"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmSwitch"><span class="hs-identifier hs-type">CmmSwitch</span></a></span><span> </span><span id="local-6989586621681020475"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020475"><span class="hs-identifier hs-var">_e</span></a></span></span><span> </span><span id="local-6989586621681020474"><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681020474"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-660"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020473"><span class="annot"><span class="annottext">switchTargets :: [Label]
</span><a href="#local-6989586621681020473"><span class="hs-identifier hs-var hs-var">switchTargets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwitchTargets -&gt; [Label]
</span><a href="GHC.Cmm.Switch.html#switchTargetsToList"><span class="hs-identifier hs-var">switchTargetsToList</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681020474"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-661"></span><span>              </span><span class="hs-comment">--Compiler performance hack - for very wide switches don't</span><span>
</span><span id="line-662"></span><span>              </span><span class="hs-comment">--consider targets for layout.</span><span>
</span><span id="line-663"></span><span>              </span><span id="local-6989586621681020471"><span class="annot"><span class="annottext">adjustedWeight :: Int
</span><a href="#local-6989586621681020471"><span class="hs-identifier hs-var hs-var">adjustedWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-664"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Label] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020473"><span class="hs-identifier hs-var">switchTargets</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">10</span></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020542"><span class="hs-identifier hs-var">switchWeight</span></a></span><span>
</span><span id="line-665"></span><span>          </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; (Edge, EdgeInfo)) -&gt; [Label] -&gt; [(Edge, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020468"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020468"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020521"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020468"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020471"><span class="hs-identifier hs-var">adjustedWeight</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020473"><span class="hs-identifier hs-var">switchTargets</span></a></span><span>
</span><span id="line-666"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCall"><span class="hs-identifier hs-type">CmmCall</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cml_cont :: CmmNode O C -&gt; Maybe Label
</span><a href="GHC.Cmm.Node.html#cml_cont"><span class="hs-identifier hs-var">cml_cont</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020463"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020463"><span class="hs-identifier hs-var">cont</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020521"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020463"><span class="hs-identifier hs-var">cont</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020540"><span class="hs-identifier hs-var">callWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-667"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmForeignCall"><span class="hs-identifier hs-type">CmmForeignCall</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">succ :: CmmNode O C -&gt; Label
</span><a href="GHC.Cmm.Node.html#succ"><span class="hs-identifier hs-var">Cmm.succ</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020458"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020458"><span class="hs-identifier hs-var">cont</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020521"><span class="hs-identifier hs-var">mkEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020458"><span class="hs-identifier hs-var">cont</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020540"><span class="hs-identifier hs-var">callWeight</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-668"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCall"><span class="hs-identifier hs-type">CmmCall</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cml_cont :: CmmNode O C -&gt; Maybe Label
</span><a href="GHC.Cmm.Node.html#cml_cont"><span class="hs-identifier hs-var">cml_cont</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Label
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-669"></span><span>        </span><span id="local-6989586621681020455"><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020455"><span class="hs-identifier hs-var">other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-670"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; [(Edge, EdgeInfo)] -&gt; [(Edge, EdgeInfo)]
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Foo&quot;</span></span><span> </span><span class="annot"><span class="annottext">([(Edge, EdgeInfo)] -&gt; [(Edge, EdgeInfo)])
-&gt; [(Edge, EdgeInfo)] -&gt; [(Edge, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-671"></span><span>            </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span class="hs-identifier">False</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-string">&quot;Unknown successor cause:&quot;</span><span> </span><span class="hs-operator">&lt;&gt;</span><span>
</span><span id="line-672"></span><span>              </span><span class="hs-special">(</span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">branch</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;=&gt;&quot;</span><span> </span><span class="hs-operator">&lt;&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">G.successors</span><span> </span><span class="hs-identifier">other</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-673"></span><span>            </span><span class="annot"><span class="annottext">(Label -&gt; (Edge, EdgeInfo)) -&gt; [Label] -&gt; [(Edge, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020452"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020452"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020490"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020452"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int -&gt; EdgeInfo
</span><a href="#local-6989586621681020451"><span class="hs-identifier hs-var">mkEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [(Edge, EdgeInfo)]) -&gt; [Label] -&gt; [(Edge, EdgeInfo)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C -&gt; [Label]
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
NonLocal thing =&gt;
thing e C -&gt; [Label]
</span><a href="GHC.Cmm.Dataflow.Graph.html#successors"><span class="hs-identifier hs-var">G.successors</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020455"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-674"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-675"></span><span>        </span><span id="local-6989586621681020490"><span class="annot"><span class="annottext">bid :: Label
</span><a href="#local-6989586621681020490"><span class="hs-identifier hs-var hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; Label
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
NonLocal thing =&gt;
thing C x -&gt; Label
</span><a href="GHC.Cmm.Dataflow.Graph.html#entryLabel"><span class="hs-identifier hs-var">G.entryLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681020527"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-676"></span><span>        </span><span id="local-6989586621681020451"><span class="annot"><span class="annottext">mkEdgeInfo :: Int -&gt; EdgeInfo
</span><a href="#local-6989586621681020451"><span class="hs-identifier hs-var hs-var">mkEdgeInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TransitionSource -&gt; EdgeWeight -&gt; EdgeInfo
</span><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-var">EdgeInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmNode O C -&gt; BranchInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-var">CmmSource</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020526"><span class="hs-identifier hs-var">branch</span></a></span><span> </span><span class="annot"><span class="annottext">BranchInfo
</span><a href="GHC.CmmToAsm.CFG.html#NoInfo"><span class="hs-identifier hs-var">NoInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; EdgeInfo) -&gt; (Int -&gt; EdgeWeight) -&gt; Int -&gt; EdgeInfo
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-677"></span><span>        </span><span id="local-6989586621681020521"><span class="annot"><span class="annottext">mkEdge :: Label -&gt; Int -&gt; (Edge, EdgeInfo)
</span><a href="#local-6989586621681020521"><span class="hs-identifier hs-var hs-var">mkEdge</span></a></span></span><span> </span><span id="local-6989586621681020450"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020450"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621681020449"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020449"><span class="hs-identifier hs-var">weight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020490"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020450"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeInfo
</span><a href="#local-6989586621681020451"><span class="hs-identifier hs-var">mkEdgeInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020449"><span class="hs-identifier hs-var">weight</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-678"></span><span>        </span><span id="local-6989586621681020526"><span class="annot"><span class="annottext">branch :: CmmNode O C
</span><a href="#local-6989586621681020526"><span class="hs-identifier hs-var hs-var">branch</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; CmmNode O C
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
Block n x C -&gt; n O C
</span><a href="GHC.Cmm.Dataflow.Block.html#lastNode"><span class="hs-identifier hs-var">lastNode</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681020527"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span>
</span><span id="line-679"></span><span>
</span><span id="line-680"></span><span>    </span><span id="local-6989586621681020548"><span class="annot"><span class="annottext">blocks :: [CmmBlock]
</span><a href="#local-6989586621681020548"><span class="hs-identifier hs-var hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmGraph -&gt; [CmmBlock]
</span><a href="GHC.Cmm.Utils.html#revPostorder"><span class="hs-identifier hs-var">revPostorder</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020552"><span class="hs-identifier hs-var">graph</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-681"></span><span>
</span><span id="line-682"></span><span class="hs-comment">--Find back edges by BFS</span><span>
</span><span id="line-683"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#findBackEdges"><span class="hs-identifier hs-type">findBackEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edges"><span class="hs-identifier hs-type">Edges</span></a></span><span>
</span><span id="line-684"></span><span id="findBackEdges"><span class="annot"><span class="annottext">findBackEdges :: HasDebugCallStack =&gt; Label -&gt; CFG -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#findBackEdges"><span class="hs-identifier hs-var hs-var">findBackEdges</span></a></span></span><span> </span><span id="local-6989586621681020439"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020439"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span id="local-6989586621681020438"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020438"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-685"></span><span>    </span><span class="hs-comment">--pprTraceIt &quot;Backedges:&quot; $</span><span>
</span><span id="line-686"></span><span>    </span><span class="annot"><span class="annottext">((Edge, EdgeType) -&gt; Edge) -&gt; [(Edge, EdgeType)] -&gt; [Edge]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Edge, EdgeType) -&gt; Edge
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">([(Edge, EdgeType)] -&gt; [Edge])
-&gt; ([(Edge, EdgeType)] -&gt; [(Edge, EdgeType)])
-&gt; [(Edge, EdgeType)]
-&gt; [Edge]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-687"></span><span>    </span><span class="annot"><span class="annottext">((Edge, EdgeType) -&gt; Bool)
-&gt; [(Edge, EdgeType)] -&gt; [(Edge, EdgeType)]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020437"><span class="annot"><span class="annottext">(Edge, EdgeType)
</span><a href="#local-6989586621681020437"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Edge, EdgeType) -&gt; EdgeType
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(Edge, EdgeType)
</span><a href="#local-6989586621681020437"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeType -&gt; EdgeType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeType
</span><a href="GHC.Data.Graph.Directed.html#Backward"><span class="hs-identifier hs-var">Backward</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([(Edge, EdgeType)] -&gt; [Edge]) -&gt; [(Edge, EdgeType)] -&gt; [Edge]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(Edge, EdgeType)]
</span><a href="#local-6989586621681020435"><span class="hs-identifier hs-var">typedEdges</span></a></span><span>
</span><span id="line-688"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-689"></span><span>    </span><span id="local-6989586621681020434"><span class="annot"><span class="annottext">edges :: [Edge]
</span><a href="#local-6989586621681020434"><span class="hs-identifier hs-var hs-var">edges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#edgeList"><span class="hs-identifier hs-var">edgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020438"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-690"></span><span>    </span><span id="local-6989586621681020433"><span class="annot"><span class="annottext">getSuccs :: Label -&gt; [Label]
</span><a href="#local-6989586621681020433"><span class="hs-identifier hs-var hs-var">getSuccs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-var">getSuccessors</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020438"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-691"></span><span>    </span><span id="local-6989586621681020435"><span class="annot"><span class="annottext">typedEdges :: [(Edge, EdgeType)]
</span><a href="#local-6989586621681020435"><span class="hs-identifier hs-var hs-var">typedEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-692"></span><span>      </span><span class="annot"><span class="annottext">Label -&gt; (Label -&gt; [Label]) -&gt; [Edge] -&gt; [(Edge, EdgeType)]
forall key.
Uniquable key =&gt;
key -&gt; (key -&gt; [key]) -&gt; [(key, key)] -&gt; [((key, key), EdgeType)]
</span><a href="GHC.Data.Graph.Directed.html#classifyEdges"><span class="hs-identifier hs-var">classifyEdges</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020439"><span class="hs-identifier hs-var">root</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; [Label]
</span><a href="#local-6989586621681020433"><span class="hs-identifier hs-var">getSuccs</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020434"><span class="hs-identifier hs-var">edges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="GHC.Data.Graph.Directed.html#EdgeType"><span class="hs-identifier hs-type">EdgeType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-693"></span><span>
</span><span id="line-694"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#optimizeCFG"><span class="hs-identifier hs-type">optimizeCFG</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CfgWeights"><span class="hs-identifier hs-type">D.CfgWeights</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#RawCmmDecl"><span class="hs-identifier hs-type">RawCmmDecl</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-695"></span><span id="optimizeCFG"><span class="annot"><span class="annottext">optimizeCFG :: Bool -&gt; CfgWeights -&gt; RawCmmDecl -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#optimizeCFG"><span class="hs-identifier hs-var hs-var">optimizeCFG</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020431"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020431"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020431"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-696"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#optimizeCFG"><span class="hs-identifier hs-var">optimizeCFG</span></a></span><span> </span><span id="local-6989586621681020430"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681020430"><span class="hs-identifier hs-var">doStaticPred</span></a></span></span><span> </span><span id="local-6989586621681020429"><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020429"><span class="hs-identifier hs-var">weights</span></a></span></span><span> </span><span id="local-6989586621681020428"><span class="annot"><span class="annottext">proc :: RawCmmDecl
</span><a href="#local-6989586621681020428"><span class="hs-identifier hs-var">proc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681020427"><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681020427"><span class="hs-identifier hs-var">_info</span></a></span></span><span> </span><span id="local-6989586621681020426"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681020426"><span class="hs-identifier hs-var">_lab</span></a></span></span><span> </span><span id="local-6989586621681020425"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681020425"><span class="hs-identifier hs-var">_live</span></a></span></span><span> </span><span id="local-6989586621681020424"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020424"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020423"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020423"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-697"></span><span>  </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681020430"><span class="hs-identifier hs-var">doStaticPred</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#staticPredCfg"><span class="hs-identifier hs-var">staticPredCfg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmGraph -&gt; Label
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
GenCmmGraph n -&gt; Label
</span><a href="GHC.Cmm.html#g_entry"><span class="hs-identifier hs-var hs-var">g_entry</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020424"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; CFG
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-698"></span><span>    </span><span class="annot"><span class="annottext">CfgWeights -&gt; RawCmmDecl -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#optHsPatterns"><span class="hs-identifier hs-var">optHsPatterns</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020429"><span class="hs-identifier hs-var">weights</span></a></span><span> </span><span class="annot"><span class="annottext">RawCmmDecl
</span><a href="#local-6989586621681020428"><span class="hs-identifier hs-var">proc</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020423"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-699"></span><span>
</span><span id="line-700"></span><span class="hs-comment">-- | Modify branch weights based on educated guess on</span><span>
</span><span id="line-701"></span><span class="hs-comment">-- patterns GHC tends to produce and how they affect</span><span>
</span><span id="line-702"></span><span class="hs-comment">-- performance.</span><span>
</span><span id="line-703"></span><span class="hs-comment">--</span><span>
</span><span id="line-704"></span><span class="hs-comment">-- Most importantly we penalize jumps across info tables.</span><span>
</span><span id="line-705"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#optHsPatterns"><span class="hs-identifier hs-type">optHsPatterns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CfgWeights"><span class="hs-identifier hs-type">D.CfgWeights</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#RawCmmDecl"><span class="hs-identifier hs-type">RawCmmDecl</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-706"></span><span id="optHsPatterns"><span class="annot"><span class="annottext">optHsPatterns :: CfgWeights -&gt; RawCmmDecl -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#optHsPatterns"><span class="hs-identifier hs-var hs-var">optHsPatterns</span></a></span></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020418"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020418"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020418"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-707"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#optHsPatterns"><span class="hs-identifier hs-var">optHsPatterns</span></a></span><span> </span><span id="local-6989586621681020417"><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020417"><span class="hs-identifier hs-var">weights</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681020416"><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681020416"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681020415"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681020415"><span class="hs-identifier hs-var">_lab</span></a></span></span><span> </span><span id="local-6989586621681020414"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681020414"><span class="hs-identifier hs-var">_live</span></a></span></span><span> </span><span id="local-6989586621681020413"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020413"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020412"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020412"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-708"></span><span>    </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">optHsPatterns</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-709"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;Initial:&quot; (pprEdgeWeights cfg) $</span><span>
</span><span id="line-710"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;Initial:&quot; (ppr $ mkGlobalWeights (g_entry graph) cfg) $</span><span>
</span><span id="line-711"></span><span>
</span><span id="line-712"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;LoopInfo:&quot; (ppr $ loopInfo cfg (g_entry graph)) $</span><span>
</span><span id="line-713"></span><span>    </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="#local-6989586621681020411"><span class="hs-identifier hs-var">favourFewerPreds</span></a></span><span>  </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-714"></span><span>    </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics -&gt; CFG -&gt; CFG
forall a. LabelMap a -&gt; CFG -&gt; CFG
</span><a href="#local-6989586621681020410"><span class="hs-identifier hs-var">penalizeInfoTables</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681020416"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; (CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-715"></span><span>    </span><span class="annot"><span class="annottext">Label -&gt; CFG -&gt; CFG
</span><a href="#local-6989586621681020409"><span class="hs-identifier hs-var">increaseBackEdgeWeight</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmGraph -&gt; Label
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
GenCmmGraph n -&gt; Label
</span><a href="GHC.Cmm.html#g_entry"><span class="hs-identifier hs-var hs-var">g_entry</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681020413"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020412"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-716"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-717"></span><span>
</span><span id="line-718"></span><span>    </span><span class="hs-comment">-- | Increase the weight of all backedges in the CFG</span><span>
</span><span id="line-719"></span><span>    </span><span class="hs-comment">-- this helps to make loop jumpbacks the heaviest edges</span><span>
</span><span id="line-720"></span><span>    </span><span class="annot"><a href="#local-6989586621681020409"><span class="hs-identifier hs-type">increaseBackEdgeWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-721"></span><span>    </span><span id="local-6989586621681020409"><span class="annot"><span class="annottext">increaseBackEdgeWeight :: Label -&gt; CFG -&gt; CFG
</span><a href="#local-6989586621681020409"><span class="hs-identifier hs-var hs-var">increaseBackEdgeWeight</span></a></span></span><span> </span><span id="local-6989586621681020408"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020408"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span id="local-6989586621681020407"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020407"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-722"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020406"><span class="annot"><span class="annottext">backedges :: [Edge]
</span><a href="#local-6989586621681020406"><span class="hs-identifier hs-var hs-var">backedges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Label -&gt; CFG -&gt; [Edge]
Label -&gt; CFG -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#findBackEdges"><span class="hs-identifier hs-var">findBackEdges</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020408"><span class="hs-identifier hs-var">root</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020407"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-723"></span><span>            </span><span id="local-6989586621681020405"><span class="annot"><span class="annottext">update :: EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020405"><span class="hs-identifier hs-var hs-var">update</span></a></span></span><span> </span><span id="local-6989586621681020404"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020404"><span class="hs-identifier hs-var">weight</span></a></span></span><span>
</span><span id="line-724"></span><span>              </span><span class="hs-comment">--Keep irrelevant edges irrelevant</span><span>
</span><span id="line-725"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020404"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span>
</span><span id="line-726"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-727"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020404"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#backEdgeBonus"><span class="hs-identifier hs-var hs-var">D.backEdgeBonus</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020417"><span class="hs-identifier hs-var">weights</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-728"></span><span>        </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">(CFG -&gt; Edge -&gt; CFG) -&gt; CFG -&gt; [Edge] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020400"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020400"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020399"><span class="annot"><span class="annottext">Edge
</span><a href="#local-6989586621681020399"><span class="hs-identifier hs-var">edge</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; EdgeWeight) -&gt; Edge -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#updateEdgeWeight"><span class="hs-identifier hs-var">updateEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020405"><span class="hs-identifier hs-var">update</span></a></span><span> </span><span class="annot"><span class="annottext">Edge
</span><a href="#local-6989586621681020399"><span class="hs-identifier hs-var">edge</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020400"><span class="hs-identifier hs-var">cfg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-729"></span><span>                    </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020407"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020406"><span class="hs-identifier hs-var">backedges</span></a></span><span>
</span><span id="line-730"></span><span>
</span><span id="line-731"></span><span>    </span><span class="hs-comment">-- | Since we cant fall through info tables we penalize these.</span><span>
</span><span id="line-732"></span><span>    </span><span id="local-6989586621681021559"><span class="annot"><a href="#local-6989586621681020410"><span class="hs-identifier hs-type">penalizeInfoTables</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021559"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span></span><span>
</span><span id="line-733"></span><span>    </span><span id="local-6989586621681020410"><span class="annot"><span class="annottext">penalizeInfoTables :: forall a. LabelMap a -&gt; CFG -&gt; CFG
</span><a href="#local-6989586621681020410"><span class="hs-identifier hs-var hs-var">penalizeInfoTables</span></a></span></span><span> </span><span id="local-6989586621681020394"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020394"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681020393"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020393"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-734"></span><span>        </span><span class="annot"><span class="annottext">(Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight) -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#mapWeights"><span class="hs-identifier hs-var">mapWeights</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020392"><span class="hs-identifier hs-var">fupdate</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020393"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-735"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-736"></span><span>        </span><span class="annot"><a href="#local-6989586621681020392"><span class="hs-identifier hs-type">fupdate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-737"></span><span>        </span><span id="local-6989586621681020392"><span class="annot"><span class="annottext">fupdate :: Label -&gt; Label -&gt; EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020392"><span class="hs-identifier hs-var hs-var">fupdate</span></a></span></span><span> </span><span class="annot"><span class="annottext">Label
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681020391"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020391"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020390"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020390"><span class="hs-identifier hs-var">weight</span></a></span></span><span>
</span><span id="line-738"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap a -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020391"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020394"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-739"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020390"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; EdgeWeight) -&gt; Int -&gt; EdgeWeight
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights -&gt; Int
</span><a href="GHC.Driver.Session.html#infoTablePenalty"><span class="hs-identifier hs-var hs-var">D.infoTablePenalty</span></a></span><span> </span><span class="annot"><span class="annottext">CfgWeights
</span><a href="#local-6989586621681020417"><span class="hs-identifier hs-var">weights</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-740"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020390"><span class="hs-identifier hs-var">weight</span></a></span><span>
</span><span id="line-741"></span><span>
</span><span id="line-742"></span><span>    </span><span class="hs-comment">-- | If a block has two successors, favour the one with fewer</span><span>
</span><span id="line-743"></span><span>    </span><span class="hs-comment">-- predecessors and/or the one allowing fall through.</span><span>
</span><span id="line-744"></span><span>    </span><span class="annot"><a href="#local-6989586621681020411"><span class="hs-identifier hs-type">favourFewerPreds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-745"></span><span>    </span><span id="local-6989586621681020411"><span class="annot"><span class="annottext">favourFewerPreds :: CFG -&gt; CFG
</span><a href="#local-6989586621681020411"><span class="hs-identifier hs-var hs-var">favourFewerPreds</span></a></span></span><span> </span><span id="local-6989586621681020388"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020388"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-746"></span><span>        </span><span class="hs-keyword">let</span><span>
</span><span id="line-747"></span><span>            </span><span id="local-6989586621681020387"><span class="annot"><span class="annottext">revCfg :: CFG
</span><a href="#local-6989586621681020387"><span class="hs-identifier hs-var hs-var">revCfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-748"></span><span>              </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#reverseEdges"><span class="hs-identifier hs-var">reverseEdges</span></a></span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; CFG) -&gt; CFG -&gt; CFG
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Label -&gt; EdgeInfo -&gt; Bool) -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#filterEdges"><span class="hs-identifier hs-var">filterEdges</span></a></span><span>
</span><span id="line-749"></span><span>                              </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020386"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020386"><span class="hs-identifier hs-var">_from</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Label -&gt; EdgeInfo -&gt; Bool
</span><a href="#local-6989586621681020385"><span class="hs-identifier hs-var">fallthroughTarget</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020388"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-750"></span><span>
</span><span id="line-751"></span><span>            </span><span id="local-6989586621681020384"><span class="annot"><span class="annottext">predCount :: Label -&gt; Int
</span><a href="#local-6989586621681020384"><span class="hs-identifier hs-var hs-var">predCount</span></a></span></span><span> </span><span id="local-6989586621681020383"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020383"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">([(Label, EdgeInfo)] -&gt; Int) -&gt; [(Label, EdgeInfo)] -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-var">getSuccessorEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020387"><span class="hs-identifier hs-var">revCfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020383"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-752"></span><span>            </span><span id="local-6989586621681020382"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020382"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020388"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-753"></span><span>
</span><span id="line-754"></span><span>            </span><span class="annot"><a href="#local-6989586621681020381"><span class="hs-identifier hs-type">modifiers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-755"></span><span>            </span><span id="local-6989586621681020381"><span class="annot"><span class="annottext">modifiers :: Int -&gt; Int -&gt; (EdgeWeight, EdgeWeight)
</span><a href="#local-6989586621681020381"><span class="hs-identifier hs-var hs-var">modifiers</span></a></span></span><span> </span><span id="local-6989586621681020380"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020380"><span class="hs-identifier hs-var">preds1</span></a></span></span><span> </span><span id="local-6989586621681020379"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020379"><span class="hs-identifier hs-var">preds2</span></a></span></span><span>
</span><span id="line-756"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020380"><span class="hs-identifier hs-var">preds1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span>  </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020379"><span class="hs-identifier hs-var">preds2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-757"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020380"><span class="hs-identifier hs-var">preds1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020379"><span class="hs-identifier hs-var">preds2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-758"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-759"></span><span>
</span><span id="line-760"></span><span>            </span><span class="annot"><a href="#local-6989586621681020378"><span class="hs-identifier hs-type">update</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-761"></span><span>            </span><span id="local-6989586621681020378"><span class="annot"><span class="annottext">update :: CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020378"><span class="hs-identifier hs-var hs-var">update</span></a></span></span><span> </span><span id="local-6989586621681020377"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020377"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020376"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020376"><span class="hs-identifier hs-var">node</span></a></span></span><span>
</span><span id="line-762"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621681020375"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020375"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020374"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020374"><span class="hs-identifier hs-var">e1</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span id="local-6989586621681020373"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020373"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020372"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020372"><span class="hs-identifier hs-var">e2</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-var">getSuccessorEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020377"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020376"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-763"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020371"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020371"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020374"><span class="hs-identifier hs-var">e1</span></a></span><span>
</span><span id="line-764"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020370"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020370"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020372"><span class="hs-identifier hs-var">e2</span></a></span><span>
</span><span id="line-765"></span><span>              </span><span class="hs-comment">--Only change the weights if there isn't already a ordering.</span><span>
</span><span id="line-766"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020371"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020370"><span class="hs-identifier hs-var">w2</span></a></span><span>
</span><span id="line-767"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020369"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020369"><span class="hs-identifier hs-var">mod1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020368"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020368"><span class="hs-identifier hs-var">mod2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; (EdgeWeight, EdgeWeight)
</span><a href="#local-6989586621681020381"><span class="hs-identifier hs-var">modifiers</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020384"><span class="hs-identifier hs-var">predCount</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020375"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020384"><span class="hs-identifier hs-var">predCount</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020373"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-768"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020367"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020367"><span class="hs-identifier hs-var">cfg'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-769"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; (EdgeWeight -&gt; EdgeWeight) -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#adjustEdgeWeight"><span class="hs-identifier hs-var">adjustEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020367"><span class="hs-identifier hs-var">cfg'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020368"><span class="hs-identifier hs-var">mod2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020376"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020373"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-770"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; (EdgeWeight -&gt; EdgeWeight) -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#adjustEdgeWeight"><span class="hs-identifier hs-var">adjustEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020377"><span class="hs-identifier hs-var">cfg</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020369"><span class="hs-identifier hs-var">mod1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020376"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020375"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-771"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-772"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020377"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-773"></span><span>        </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; Label -&gt; CFG) -&gt; CFG -&gt; [Label] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020378"><span class="hs-identifier hs-var">update</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020388"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020382"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-774"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-775"></span><span>        </span><span class="annot"><a href="#local-6989586621681020385"><span class="hs-identifier hs-type">fallthroughTarget</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-776"></span><span>        </span><span id="local-6989586621681020385"><span class="annot"><span class="annottext">fallthroughTarget :: Label -&gt; EdgeInfo -&gt; Bool
</span><a href="#local-6989586621681020385"><span class="hs-identifier hs-var hs-var">fallthroughTarget</span></a></span></span><span> </span><span id="local-6989586621681020366"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020366"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span> </span><span id="local-6989586621681020365"><span class="annot"><span class="annottext">TransitionSource
</span><a href="#local-6989586621681020365"><span class="hs-identifier hs-var">source</span></a></span></span><span> </span><span id="local-6989586621681020364"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020364"><span class="hs-identifier hs-var">_weight</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-777"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap RawCmmStatics -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-identifier hs-var">mapMember</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020366"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><a href="#local-6989586621681020416"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-778"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#AsmCodeGen"><span class="hs-identifier hs-var">AsmCodeGen</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><a href="#local-6989586621681020365"><span class="hs-identifier hs-var">source</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-779"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmBranch"><span class="hs-identifier hs-type">CmmBranch</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><a href="#local-6989586621681020365"><span class="hs-identifier hs-var">source</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-780"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-type">CmmCondBranch</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TransitionSource
</span><a href="#local-6989586621681020365"><span class="hs-identifier hs-var">source</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-781"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-782"></span><span>
</span><span id="line-783"></span><span class="hs-comment">-- | Convert block-local branch weights to global weights.</span><span>
</span><span id="line-784"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#staticPredCfg"><span class="hs-identifier hs-type">staticPredCfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-785"></span><span id="staticPredCfg"><span class="annot"><span class="annottext">staticPredCfg :: Label -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#staticPredCfg"><span class="hs-identifier hs-var hs-var">staticPredCfg</span></a></span></span><span> </span><span id="local-6989586621681020359"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020359"><span class="hs-identifier hs-var">entry</span></a></span></span><span> </span><span id="local-6989586621681020358"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020358"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020357"><span class="hs-identifier hs-var">cfg'</span></a></span><span>
</span><span id="line-786"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-787"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap Double
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020356"><span class="annot"><span class="annottext">LabelMap (LabelMap Double)
</span><a href="#local-6989586621681020356"><span class="hs-identifier hs-var">globalEdgeWeights</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">mkGlobalWeights</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-788"></span><span>                             </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt;
Label -&gt; CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double))
Label -&gt; CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double))
</span><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-identifier hs-var">mkGlobalWeights</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020359"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020358"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-789"></span><span>    </span><span id="local-6989586621681020357"><span class="annot"><span class="annottext">cfg' :: CFG
</span><a href="#local-6989586621681020357"><span class="hs-identifier hs-var hs-var">cfg'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">rewriteEdges</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-790"></span><span>            </span><span class="annot"><span class="annottext">(CFG -&gt; KeyOf LabelMap -&gt; LabelMap Double -&gt; CFG)
-&gt; CFG -&gt; LabelMap (LabelMap Double) -&gt; CFG
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span>
</span><span id="line-791"></span><span>                </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020355"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020355"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020354"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681020354"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020353"><span class="annot"><span class="annottext">LabelMap Double
</span><a href="#local-6989586621681020353"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-792"></span><span>                    </span><span class="annot"><span class="annottext">(CFG -&gt; KeyOf LabelMap -&gt; Double -&gt; CFG)
-&gt; CFG -&gt; LabelMap Double -&gt; CFG
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span>
</span><span id="line-793"></span><span>                        </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020352"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020352"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020351"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681020351"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621681020350"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020350"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020352"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-var">EdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020350"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020354"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020351"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-794"></span><span>                        </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020355"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Double
</span><a href="#local-6989586621681020353"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-795"></span><span>                </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020358"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-796"></span><span>                </span><span class="annot"><span class="annottext">LabelMap (LabelMap Double)
</span><a href="#local-6989586621681020356"><span class="hs-identifier hs-var">globalEdgeWeights</span></a></span><span>
</span><span id="line-797"></span><span>
</span><span id="line-798"></span><span class="hs-comment">-- | Determine loop membership of blocks based on SCC analysis</span><span>
</span><span id="line-799"></span><span class="hs-comment">--   This is faster but only gives yes/no answers.</span><span>
</span><span id="line-800"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopMembers"><span class="hs-identifier hs-type">loopMembers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-801"></span><span id="loopMembers"><span class="annot"><span class="annottext">loopMembers :: HasDebugCallStack =&gt; CFG -&gt; LabelMap Bool
</span><a href="GHC.CmmToAsm.CFG.html#loopMembers"><span class="hs-identifier hs-var hs-var">loopMembers</span></a></span></span><span> </span><span id="local-6989586621681020341"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020341"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-802"></span><span>    </span><span class="annot"><span class="annottext">(LabelMap Bool -&gt; SCC Label -&gt; LabelMap Bool)
-&gt; LabelMap Bool -&gt; [SCC Label] -&gt; LabelMap Bool
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SCC Label -&gt; LabelMap Bool -&gt; LabelMap Bool)
-&gt; LabelMap Bool -&gt; SCC Label -&gt; LabelMap Bool
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">SCC Label -&gt; LabelMap Bool -&gt; LabelMap Bool
</span><a href="#local-6989586621681020340"><span class="hs-identifier hs-var">setLevel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[SCC Label]
</span><a href="#local-6989586621681020339"><span class="hs-identifier hs-var">sccs</span></a></span><span>
</span><span id="line-803"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-804"></span><span>    </span><span class="annot"><a href="#local-6989586621681020338"><span class="hs-identifier hs-type">mkNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-805"></span><span>    </span><span id="local-6989586621681020338"><span class="annot"><span class="annottext">mkNode :: Label -&gt; Node Label Label
</span><a href="#local-6989586621681020338"><span class="hs-identifier hs-var hs-var">mkNode</span></a></span></span><span> </span><span id="local-6989586621681020337"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020337"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; [Label] -&gt; Node Label Label
forall key payload. payload -&gt; key -&gt; [key] -&gt; Node key payload
</span><a href="GHC.Data.Graph.Directed.html#DigraphNode"><span class="hs-identifier hs-var">DigraphNode</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020337"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020337"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-var">getSuccessors</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020341"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020337"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-806"></span><span>    </span><span id="local-6989586621681020335"><span class="annot"><span class="annottext">nodes :: [Node Label Label]
</span><a href="#local-6989586621681020335"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Node Label Label) -&gt; [Label] -&gt; [Node Label Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Node Label Label
</span><a href="#local-6989586621681020338"><span class="hs-identifier hs-var">mkNode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020341"><span class="hs-identifier hs-var">cfg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span>    </span><span id="local-6989586621681020339"><span class="annot"><span class="annottext">sccs :: [SCC Label]
</span><a href="#local-6989586621681020339"><span class="hs-identifier hs-var hs-var">sccs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Node Label Label] -&gt; [SCC Label]
forall key payload. Ord key =&gt; [Node key payload] -&gt; [SCC payload]
</span><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesOrd"><span class="hs-identifier hs-var">stronglyConnCompFromEdgedVerticesOrd</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Label Label]
</span><a href="#local-6989586621681020335"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-809"></span><span>
</span><span id="line-810"></span><span>    </span><span class="annot"><a href="#local-6989586621681020340"><span class="hs-identifier hs-type">setLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#SCC"><span class="hs-identifier hs-type">SCC</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-811"></span><span>    </span><span id="local-6989586621681020340"><span class="annot"><span class="annottext">setLevel :: SCC Label -&gt; LabelMap Bool -&gt; LabelMap Bool
</span><a href="#local-6989586621681020340"><span class="hs-identifier hs-var hs-var">setLevel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#AcyclicSCC"><span class="hs-identifier hs-type">AcyclicSCC</span></a></span><span> </span><span id="local-6989586621681020332"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020332"><span class="hs-identifier hs-var">bid</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020331"><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020331"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; Bool -&gt; LabelMap Bool -&gt; LabelMap Bool
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020332"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020331"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-812"></span><span>    </span><span class="annot"><a href="#local-6989586621681020340"><span class="hs-identifier hs-var">setLevel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#CyclicSCC"><span class="hs-identifier hs-type">CyclicSCC</span></a></span><span> </span><span id="local-6989586621681020329"><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020329"><span class="hs-identifier hs-var">bids</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020328"><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020328"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LabelMap Bool -&gt; Label -&gt; LabelMap Bool)
-&gt; LabelMap Bool -&gt; [Label] -&gt; LabelMap Bool
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020327"><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020327"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020326"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020326"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; Bool -&gt; LabelMap Bool -&gt; LabelMap Bool
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020326"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020327"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap Bool
</span><a href="#local-6989586621681020328"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020329"><span class="hs-identifier hs-var">bids</span></a></span><span>
</span><span id="line-813"></span><span>
</span><span id="line-814"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopLevels"><span class="hs-identifier hs-type">loopLevels</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-815"></span><span id="loopLevels"><span class="annot"><span class="annottext">loopLevels :: CFG -&gt; Label -&gt; LabelMap Int
</span><a href="GHC.CmmToAsm.CFG.html#loopLevels"><span class="hs-identifier hs-var hs-var">loopLevels</span></a></span></span><span> </span><span id="local-6989586621681020325"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020325"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020324"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020324"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LoopInfo -&gt; LabelMap Int
</span><a href="GHC.CmmToAsm.CFG.html#liLevels"><span class="hs-identifier hs-var hs-var">liLevels</span></a></span><span> </span><span class="annot"><span class="annottext">LoopInfo
</span><a href="#local-6989586621681020322"><span class="hs-identifier hs-var">loopInfos</span></a></span><span>
</span><span id="line-816"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-817"></span><span>      </span><span id="local-6989586621681020322"><span class="annot"><span class="annottext">loopInfos :: LoopInfo
</span><a href="#local-6989586621681020322"><span class="hs-identifier hs-var hs-var">loopInfos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; LoopInfo
CFG -&gt; Label -&gt; LoopInfo
</span><a href="GHC.CmmToAsm.CFG.html#loopInfo"><span class="hs-identifier hs-var">loopInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020325"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020324"><span class="hs-identifier hs-var">root</span></a></span><span>
</span><span id="line-818"></span><span>
</span><span id="line-819"></span><span class="hs-keyword">data</span><span> </span><span id="LoopInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-var">LoopInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="LoopInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-var">LoopInfo</span></a></span></span><span>
</span><span id="line-820"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="liBackEdges"><span class="annot"><span class="annottext">LoopInfo -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#liBackEdges"><span class="hs-identifier hs-var hs-var">liBackEdges</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ List of back edges</span><span>
</span><span id="line-821"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="liLevels"><span class="annot"><span class="annottext">LoopInfo -&gt; LabelMap Int
</span><a href="GHC.CmmToAsm.CFG.html#liLevels"><span class="hs-identifier hs-var hs-var">liLevels</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-comment">-- ^ BlockId -&gt; LoopLevel mapping</span><span>
</span><span id="line-822"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="liLoops"><span class="annot"><span class="annottext">LoopInfo -&gt; [(Edge, LabelSet)]
</span><a href="GHC.CmmToAsm.CFG.html#liLoops"><span class="hs-identifier hs-var hs-var">liLoops</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ (backEdge, loopBody), body includes header</span><span>
</span><span id="line-823"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-824"></span><span>
</span><span id="line-825"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681020316"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-826"></span><span>    </span><span id="local-6989586621681020312"><span class="annot"><span class="annottext">ppr :: LoopInfo -&gt; SDoc
</span><a href="#local-6989586621681020312"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681020311"><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020311"><span class="hs-identifier hs-var">_lvls</span></a></span></span><span> </span><span id="local-6989586621681020310"><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020310"><span class="hs-identifier hs-var">loops</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-827"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Loops:(backEdge, bodyNodes)&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-828"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Edge, LabelSet) -&gt; SDoc) -&gt; [(Edge, LabelSet)] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Edge, LabelSet) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020310"><span class="hs-identifier hs-var">loops</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-829"></span><span>
</span><span id="line-830"></span><span class="hs-comment">{-  Note [Determining the loop body]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Starting with the knowledge that:
    * head dominates the loop
    * `tail` -&gt; `head` is a backedge

    We can determine all nodes by:
    * Deleting the loop head from the graph.
    * Collect all blocks which are reachable from the `tail`.

    We do so by performing bfs from the tail node towards the head.
 -}</span><span>
</span><span id="line-843"></span><span>
</span><span id="line-844"></span><span class="hs-comment">-- | Determine loop membership of blocks based on Dominator analysis.</span><span>
</span><span id="line-845"></span><span class="hs-comment">--   This is slower but gives loop levels instead of just loop membership.</span><span>
</span><span id="line-846"></span><span class="hs-comment">--   However it only detects natural loops. Irreducible control flow is not</span><span>
</span><span id="line-847"></span><span class="hs-comment">--   recognized even if it loops. But that is rare enough that we don't have</span><span>
</span><span id="line-848"></span><span class="hs-comment">--   to care about that special case.</span><span>
</span><span id="line-849"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#loopInfo"><span class="hs-identifier hs-type">loopInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span>
</span><span id="line-850"></span><span id="loopInfo"><span class="annot"><span class="annottext">loopInfo :: HasDebugCallStack =&gt; CFG -&gt; Label -&gt; LoopInfo
</span><a href="GHC.CmmToAsm.CFG.html#loopInfo"><span class="hs-identifier hs-var hs-var">loopInfo</span></a></span></span><span> </span><span id="local-6989586621681020275"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020275"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020274"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020274"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LoopInfo :: [Edge] -&gt; LabelMap Int -&gt; [(Edge, LabelSet)] -&gt; LoopInfo
</span><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">liBackEdges :: [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#liBackEdges"><span class="hs-identifier hs-var">liBackEdges</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020273"><span class="hs-identifier hs-var">backEdges</span></a></span><span>
</span><span id="line-851"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">liLevels :: LabelMap Int
</span><a href="GHC.CmmToAsm.CFG.html#liLevels"><span class="hs-identifier hs-var">liLevels</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Int)] -&gt; LabelMap Int
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Int)]
[(Label, Int)]
</span><a href="#local-6989586621681020272"><span class="hs-identifier hs-var">loopCounts</span></a></span><span>
</span><span id="line-852"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">liLoops :: [(Edge, LabelSet)]
</span><a href="GHC.CmmToAsm.CFG.html#liLoops"><span class="hs-identifier hs-var">liLoops</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020271"><span class="hs-identifier hs-var">loopBodies</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-853"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-854"></span><span>    </span><span id="local-6989586621681020270"><span class="annot"><span class="annottext">revCfg :: CFG
</span><a href="#local-6989586621681020270"><span class="hs-identifier hs-var hs-var">revCfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#reverseEdges"><span class="hs-identifier hs-var">reverseEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020275"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-855"></span><span>
</span><span id="line-856"></span><span>    </span><span id="local-6989586621681020269"><span class="annot"><span class="annottext">graph :: LabelMap LabelSet
</span><a href="#local-6989586621681020269"><span class="hs-identifier hs-var hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;CFG - loopInfo&quot; (pprEdgeWeights cfg) $</span><span>
</span><span id="line-857"></span><span>            </span><span class="annot"><span class="annottext">(LabelMap EdgeInfo -&gt; LabelSet) -&gt; CFG -&gt; LabelMap LabelSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Label] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; LabelSet)
-&gt; (LabelMap EdgeInfo -&gt; [Label]) -&gt; LabelMap EdgeInfo -&gt; LabelSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; [Label]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020275"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span>
</span><span id="line-860"></span><span>    </span><span class="hs-comment">--TODO - This should be a no op: Export constructors? Use unsafeCoerce? ...</span><span>
</span><span id="line-861"></span><span>    </span><span id="local-6989586621681020268"><span class="annot"><span class="annottext">rooted :: (Int, IntMap IntSet)
</span><a href="#local-6989586621681020268"><span class="hs-identifier hs-var hs-var">rooted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020267"><span class="hs-identifier hs-var">fromBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020274"><span class="hs-identifier hs-var">root</span></a></span><span>
</span><span id="line-862"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LabelMap IntSet -&gt; IntMap IntSet
forall a. LabelMap a -&gt; IntMap a
</span><a href="#local-6989586621681020266"><span class="hs-identifier hs-var">toIntMap</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap IntSet -&gt; IntMap IntSet)
-&gt; LabelMap IntSet -&gt; IntMap IntSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelSet -&gt; IntSet) -&gt; LabelMap LabelSet -&gt; LabelMap IntSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; IntSet
</span><a href="#local-6989586621681020265"><span class="hs-identifier hs-var">toIntSet</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap LabelSet
</span><a href="#local-6989586621681020269"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IntMap</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-863"></span><span>    </span><span id="local-6989586621681020264"><span class="annot"><span class="annottext">tree :: Tree Label
</span><a href="#local-6989586621681020264"><span class="hs-identifier hs-var hs-var">tree</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Label) -&gt; Tree Int -&gt; Tree Label
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Label
</span><a href="#local-6989586621681020263"><span class="hs-identifier hs-var">toBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">(Tree Int -&gt; Tree Label) -&gt; Tree Int -&gt; Tree Label
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Int, IntMap IntSet) -&gt; Tree Int
</span><a href="GHC.CmmToAsm.CFG.Dominators.html#domTree"><span class="hs-identifier hs-var">Dom.domTree</span></a></span><span> </span><span class="annot"><span class="annottext">(Int, IntMap IntSet)
</span><a href="#local-6989586621681020268"><span class="hs-identifier hs-var">rooted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Tree.html#Tree"><span class="hs-identifier hs-type">Tree</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-864"></span><span>
</span><span id="line-865"></span><span>    </span><span class="hs-comment">-- Map from Nodes to their dominators</span><span>
</span><span id="line-866"></span><span>    </span><span class="annot"><a href="#local-6989586621681020261"><span class="hs-identifier hs-type">domMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-867"></span><span>    </span><span id="local-6989586621681020261"><span class="annot"><span class="annottext">domMap :: LabelMap LabelSet
</span><a href="#local-6989586621681020261"><span class="hs-identifier hs-var hs-var">domMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tree Label -&gt; LabelMap LabelSet
</span><a href="#local-6989586621681020260"><span class="hs-identifier hs-var">mkDomMap</span></a></span><span> </span><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020264"><span class="hs-identifier hs-var">tree</span></a></span><span>
</span><span id="line-868"></span><span>
</span><span id="line-869"></span><span>    </span><span id="local-6989586621681020259"><span class="annot"><span class="annottext">edges :: [Edge]
</span><a href="#local-6989586621681020259"><span class="hs-identifier hs-var hs-var">edges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Edge]
</span><a href="GHC.CmmToAsm.CFG.html#edgeList"><span class="hs-identifier hs-var">edgeList</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020275"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-870"></span><span>    </span><span class="hs-comment">-- We can't recompute nodes from edges, there might be blocks not connected via edges.</span><span>
</span><span id="line-871"></span><span>    </span><span id="local-6989586621681020258"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020258"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020275"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-872"></span><span>
</span><span id="line-873"></span><span>    </span><span class="hs-comment">-- identify back edges</span><span>
</span><span id="line-874"></span><span>    </span><span id="local-6989586621681020255"><span class="annot"><span class="annottext">isBackEdge :: Edge -&gt; Bool
</span><a href="#local-6989586621681020255"><span class="hs-identifier hs-var hs-var">isBackEdge</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020254"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020254"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020253"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020253"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-875"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681020252"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020252"><span class="hs-identifier hs-var">doms</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap LabelSet -&gt; Maybe LabelSet
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020254"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap LabelSet
</span><a href="#local-6989586621681020261"><span class="hs-identifier hs-var">domMap</span></a></span><span>
</span><span id="line-876"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020253"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020252"><span class="hs-identifier hs-var">doms</span></a></span><span>
</span><span id="line-877"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-878"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-879"></span><span>
</span><span id="line-880"></span><span>    </span><span class="hs-comment">-- See Note [Determining the loop body]</span><span>
</span><span id="line-881"></span><span>    </span><span class="hs-comment">-- Get the loop body associated with a back edge.</span><span>
</span><span id="line-882"></span><span>    </span><span id="local-6989586621681020251"><span class="annot"><span class="annottext">findBody :: Edge -&gt; (Edge, LabelSet)
</span><a href="#local-6989586621681020251"><span class="hs-identifier hs-var hs-var">findBody</span></a></span></span><span> </span><span id="local-6989586621681020250"><span class="annot"><span class="annottext">edge :: Edge
</span><a href="#local-6989586621681020250"><span class="hs-identifier hs-var">edge</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681020249"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020249"><span class="hs-identifier hs-var">tail</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020248"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020248"><span class="hs-identifier hs-var">head</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-883"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Edge
</span><a href="#local-6989586621681020250"><span class="hs-identifier hs-var">edge</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020248"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelSet -&gt; LabelSet) -&gt; LabelSet -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
</span><a href="#local-6989586621681020246"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setSingleton"><span class="hs-identifier hs-var">setSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020249"><span class="hs-identifier hs-var">tail</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setSingleton"><span class="hs-identifier hs-var">setSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020249"><span class="hs-identifier hs-var">tail</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-884"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-885"></span><span>        </span><span class="hs-comment">-- See Note [Determining the loop body]</span><span>
</span><span id="line-886"></span><span>
</span><span id="line-887"></span><span>
</span><span id="line-888"></span><span>        </span><span class="annot"><a href="#local-6989586621681020246"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-889"></span><span>        </span><span id="local-6989586621681020246"><span class="annot"><span class="annottext">go :: LabelSet -&gt; LabelSet -&gt; LabelSet
</span><a href="#local-6989586621681020246"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681020244"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020244"><span class="hs-identifier hs-var">found</span></a></span></span><span> </span><span id="local-6989586621681020243"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020243"><span class="hs-identifier hs-var">current</span></a></span></span><span>
</span><span id="line-890"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; Bool
forall set. IsSet set =&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setNull"><span class="hs-identifier hs-var">setNull</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020243"><span class="hs-identifier hs-var">current</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020244"><span class="hs-identifier hs-var">found</span></a></span><span>
</span><span id="line-891"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
</span><a href="#local-6989586621681020246"><span class="hs-identifier hs-var">go</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setUnion"><span class="hs-identifier hs-var">setUnion</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020241"><span class="hs-identifier hs-var">newSuccessors</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020244"><span class="hs-identifier hs-var">found</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-892"></span><span>                            </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020241"><span class="hs-identifier hs-var">newSuccessors</span></a></span><span>
</span><span id="line-893"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-894"></span><span>            </span><span class="hs-comment">-- Really predecessors, since we use the reversed cfg.</span><span>
</span><span id="line-895"></span><span>            </span><span id="local-6989586621681020241"><span class="annot"><span class="annottext">newSuccessors :: LabelSet
</span><a href="#local-6989586621681020241"><span class="hs-identifier hs-var hs-var">newSuccessors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ElemOf LabelSet -&gt; Bool) -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; (ElemOf set -&gt; Bool) -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFilter"><span class="hs-identifier hs-var">setFilter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020239"><span class="annot"><span class="annottext">ElemOf LabelSet
</span><a href="#local-6989586621681020239"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
</span><a href="#local-6989586621681020239"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020244"><span class="hs-identifier hs-var">found</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020238"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-896"></span><span>            </span><span id="local-6989586621681020238"><span class="annot"><span class="annottext">successors :: LabelSet
</span><a href="#local-6989586621681020238"><span class="hs-identifier hs-var hs-var">successors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setDelete"><span class="hs-identifier hs-var">setDelete</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020248"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelSet -&gt; LabelSet) -&gt; LabelSet -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setUnions"><span class="hs-identifier hs-var">setUnions</span></a></span><span> </span><span class="annot"><span class="annottext">([LabelSet] -&gt; LabelSet) -&gt; [LabelSet] -&gt; LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; LabelSet) -&gt; [Label] -&gt; [LabelSet]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span>
</span><span id="line-897"></span><span>                                      </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020235"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020235"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020235"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020248"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">LabelSet
forall set. IsSet set =&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setEmpty"><span class="hs-identifier hs-var">setEmpty</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[ElemOf LabelSet] -&gt; LabelSet
forall set. IsSet set =&gt; [ElemOf set] -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setFromList"><span class="hs-identifier hs-var">setFromList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-var">getSuccessors</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020270"><span class="hs-identifier hs-var">revCfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020235"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-898"></span><span>                                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelSet -&gt; [ElemOf LabelSet]
forall set. IsSet set =&gt; set -&gt; [ElemOf set]
</span><a href="GHC.Cmm.Dataflow.Collections.html#setElems"><span class="hs-identifier hs-var">setElems</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020243"><span class="hs-identifier hs-var">current</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-899"></span><span>
</span><span id="line-900"></span><span>    </span><span id="local-6989586621681020273"><span class="annot"><span class="annottext">backEdges :: [Edge]
</span><a href="#local-6989586621681020273"><span class="hs-identifier hs-var hs-var">backEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Edge -&gt; Bool) -&gt; [Edge] -&gt; [Edge]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Edge -&gt; Bool
</span><a href="#local-6989586621681020255"><span class="hs-identifier hs-var">isBackEdge</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020259"><span class="hs-identifier hs-var">edges</span></a></span><span>
</span><span id="line-901"></span><span>    </span><span id="local-6989586621681020271"><span class="annot"><span class="annottext">loopBodies :: [(Edge, LabelSet)]
</span><a href="#local-6989586621681020271"><span class="hs-identifier hs-var hs-var">loopBodies</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Edge -&gt; (Edge, LabelSet)) -&gt; [Edge] -&gt; [(Edge, LabelSet)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Edge -&gt; (Edge, LabelSet)
</span><a href="#local-6989586621681020251"><span class="hs-identifier hs-var">findBody</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020273"><span class="hs-identifier hs-var">backEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-902"></span><span>
</span><span id="line-903"></span><span>    </span><span class="hs-comment">-- Block b is part of n loop bodies =&gt; loop nest level of n</span><span>
</span><span id="line-904"></span><span>    </span><span id="local-6989586621681020272"><span class="annot"><span class="annottext">loopCounts :: [(Label, Int)]
</span><a href="#local-6989586621681020272"><span class="hs-identifier hs-var hs-var">loopCounts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-905"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020232"><span class="annot"><span class="annottext">bodies :: [(Label, LabelSet)]
</span><a href="#local-6989586621681020232"><span class="hs-identifier hs-var hs-var">bodies</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Edge, LabelSet) -&gt; (Label, LabelSet))
-&gt; [(Edge, LabelSet)] -&gt; [(Label, LabelSet)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Edge -&gt; Label) -&gt; (Edge, LabelSet) -&gt; (Label, LabelSet)
forall (p :: * -&gt; * -&gt; *) a b c.
Bifunctor p =&gt;
(a -&gt; b) -&gt; p a c -&gt; p b c
</span><a href="../../base/src/Data.Bifunctor.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Edge -&gt; Label
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020271"><span class="hs-identifier hs-var">loopBodies</span></a></span><span> </span><span class="hs-comment">-- [(Header, Body)]</span><span>
</span><span id="line-906"></span><span>          </span><span id="local-6989586621681020230"><span class="annot"><span class="annottext">loopCount :: Label -&gt; Int
</span><a href="#local-6989586621681020230"><span class="hs-identifier hs-var hs-var">loopCount</span></a></span></span><span> </span><span id="local-6989586621681020229"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020229"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; Int) -&gt; [Label] -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [Label]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [Label])
-&gt; ([(Label, LabelSet)] -&gt; [Label])
-&gt; [(Label, LabelSet)]
-&gt; [Label]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((Label, LabelSet) -&gt; Label) -&gt; [(Label, LabelSet)] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, LabelSet) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">([(Label, LabelSet)] -&gt; [Label])
-&gt; ([(Label, LabelSet)] -&gt; [(Label, LabelSet)])
-&gt; [(Label, LabelSet)]
-&gt; [Label]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((Label, LabelSet) -&gt; Bool)
-&gt; [(Label, LabelSet)] -&gt; [(Label, LabelSet)]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; Bool
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#setMember"><span class="hs-identifier hs-var">setMember</span></a></span><span> </span><span class="annot"><span class="annottext">ElemOf LabelSet
Label
</span><a href="#local-6989586621681020229"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelSet -&gt; Bool)
-&gt; ((Label, LabelSet) -&gt; LabelSet) -&gt; (Label, LabelSet) -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, LabelSet) -&gt; LabelSet
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([(Label, LabelSet)] -&gt; [Label]) -&gt; [(Label, LabelSet)] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelSet)]
</span><a href="#local-6989586621681020232"><span class="hs-identifier hs-var">bodies</span></a></span><span>
</span><span id="line-907"></span><span>      </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">(Label -&gt; (Label, Int)) -&gt; [Label] -&gt; [(Label, Int)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020228"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020228"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020228"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020230"><span class="hs-identifier hs-var">loopCount</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020228"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [(Label, Int)]) -&gt; [Label] -&gt; [(Label, Int)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020258"><span class="hs-identifier hs-var">nodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-908"></span><span>
</span><span id="line-909"></span><span>    </span><span class="annot"><a href="#local-6989586621681020265"><span class="hs-identifier hs-type">toIntSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span>
</span><span id="line-910"></span><span>    </span><span id="local-6989586621681020265"><span class="annot"><span class="annottext">toIntSet :: LabelSet -&gt; IntSet
</span><a href="#local-6989586621681020265"><span class="hs-identifier hs-var hs-var">toIntSet</span></a></span></span><span> </span><span id="local-6989586621681020227"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020227"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int] -&gt; IntSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#fromList"><span class="hs-identifier hs-var">IS.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([Int] -&gt; IntSet) -&gt; (LabelSet -&gt; [Int]) -&gt; LabelSet -&gt; IntSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Int) -&gt; [Label] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020267"><span class="hs-identifier hs-var">fromBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [Int]) -&gt; (LabelSet -&gt; [Label]) -&gt; LabelSet -&gt; [Int]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; [Label]
forall set. IsSet set =&gt; set -&gt; [ElemOf set]
</span><a href="GHC.Cmm.Dataflow.Collections.html#setElems"><span class="hs-identifier hs-var">setElems</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelSet -&gt; IntSet) -&gt; LabelSet -&gt; IntSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020227"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-911"></span><span>    </span><span id="local-6989586621681021542"><span class="annot"><a href="#local-6989586621681020266"><span class="hs-identifier hs-type">toIntMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021542"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IntMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021542"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-912"></span><span>    </span><span id="local-6989586621681020266"><span class="annot"><span class="annottext">toIntMap :: forall a. LabelMap a -&gt; IntMap a
</span><a href="#local-6989586621681020266"><span class="hs-identifier hs-var hs-var">toIntMap</span></a></span></span><span> </span><span id="local-6989586621681020224"><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020224"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Int, a)] -&gt; IntMap a
forall a. [(Int, a)] -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">IM.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(Int, a)] -&gt; IntMap a) -&gt; [(Int, a)] -&gt; IntMap a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Label, a) -&gt; (Int, a)) -&gt; [(Label, a)] -&gt; [(Int, a)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681020222"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020222"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020221"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020221"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020267"><span class="hs-identifier hs-var">fromBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020222"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681020221"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([(Label, a)] -&gt; [(Int, a)]) -&gt; [(Label, a)] -&gt; [(Int, a)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a -&gt; [(KeyOf LabelMap, a)]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [(KeyOf map, a)]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapToList"><span class="hs-identifier hs-var">mapToList</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap a
</span><a href="#local-6989586621681020224"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-913"></span><span>
</span><span id="line-914"></span><span>    </span><span class="annot"><a href="#local-6989586621681020260"><span class="hs-identifier hs-type">mkDomMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Tree.html#Tree"><span class="hs-identifier hs-type">Tree</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-915"></span><span>    </span><span id="local-6989586621681020260"><span class="annot"><span class="annottext">mkDomMap :: Tree Label -&gt; LabelMap LabelSet
</span><a href="#local-6989586621681020260"><span class="hs-identifier hs-var hs-var">mkDomMap</span></a></span></span><span> </span><span id="local-6989586621681020220"><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020220"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, LabelSet)] -&gt; LabelMap LabelSet
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, LabelSet)] -&gt; LabelMap LabelSet)
-&gt; [(KeyOf LabelMap, LabelSet)] -&gt; LabelMap LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; Tree Label -&gt; [(Label, LabelSet)]
</span><a href="#local-6989586621681020219"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">LabelSet
forall set. IsSet set =&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setEmpty"><span class="hs-identifier hs-var">setEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020220"><span class="hs-identifier hs-var">root</span></a></span><span>
</span><span id="line-916"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-917"></span><span>        </span><span class="annot"><a href="#local-6989586621681020219"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Tree.html#Tree"><span class="hs-identifier hs-type">Tree</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-918"></span><span>        </span><span id="local-6989586621681020219"><span class="annot"><span class="annottext">go :: LabelSet -&gt; Tree Label -&gt; [(Label, LabelSet)]
</span><a href="#local-6989586621681020219"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681020218"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020218"><span class="hs-identifier hs-var">parents</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Tree.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span id="local-6989586621681020216"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020216"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-919"></span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020216"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020218"><span class="hs-identifier hs-var">parents</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-920"></span><span>        </span><span class="annot"><a href="#local-6989586621681020219"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681020215"><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020215"><span class="hs-identifier hs-var">parents</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Tree.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681020214"><span class="annot"><span class="annottext">[Tree Label]
</span><a href="#local-6989586621681020214"><span class="hs-identifier hs-var">leaves</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-921"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681020213"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020213"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tree Label -&gt; Label) -&gt; [Tree Label] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Tree Label -&gt; Label
forall a. Tree a -&gt; a
</span><a href="../../containers/src/Data.Tree.html#rootLabel"><span class="hs-identifier hs-var hs-var">rootLabel</span></a></span><span> </span><span class="annot"><span class="annottext">[Tree Label]
</span><a href="#local-6989586621681020214"><span class="hs-identifier hs-var">leaves</span></a></span><span>
</span><span id="line-922"></span><span>                </span><span id="local-6989586621681020211"><span class="annot"><span class="annottext">entries :: [(Label, LabelSet)]
</span><a href="#local-6989586621681020211"><span class="hs-identifier hs-var hs-var">entries</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; (Label, LabelSet)) -&gt; [Label] -&gt; [(Label, LabelSet)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020210"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020210"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020210"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020215"><span class="hs-identifier hs-var">parents</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020213"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-923"></span><span>            </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">[(Label, LabelSet)]
</span><a href="#local-6989586621681020211"><span class="hs-identifier hs-var">entries</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, LabelSet)] -&gt; [(Label, LabelSet)] -&gt; [(Label, LabelSet)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Tree Label -&gt; [(Label, LabelSet)])
-&gt; [Tree Label] -&gt; [(Label, LabelSet)]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span>
</span><span id="line-924"></span><span>                            </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020209"><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020209"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LabelSet -&gt; Tree Label -&gt; [(Label, LabelSet)]
</span><a href="#local-6989586621681020219"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElemOf LabelSet -&gt; LabelSet -&gt; LabelSet
forall set. IsSet set =&gt; ElemOf set -&gt; set -&gt; set
</span><a href="GHC.Cmm.Dataflow.Collections.html#setInsert"><span class="hs-identifier hs-var">setInsert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tree Label -&gt; Label
forall a. Tree a -&gt; a
</span><a href="../../containers/src/Data.Tree.html#rootLabel"><span class="hs-identifier hs-var hs-var">rootLabel</span></a></span><span> </span><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020209"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelSet
</span><a href="#local-6989586621681020215"><span class="hs-identifier hs-var">parents</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tree Label
</span><a href="#local-6989586621681020209"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-925"></span><span>                            </span><span class="annot"><span class="annottext">[Tree Label]
</span><a href="#local-6989586621681020214"><span class="hs-identifier hs-var">leaves</span></a></span><span>
</span><span id="line-926"></span><span>
</span><span id="line-927"></span><span>    </span><span class="annot"><a href="#local-6989586621681020267"><span class="hs-identifier hs-type">fromBlockId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-928"></span><span>    </span><span id="local-6989586621681020267"><span class="annot"><span class="annottext">fromBlockId :: Label -&gt; Int
</span><a href="#local-6989586621681020267"><span class="hs-identifier hs-var hs-var">fromBlockId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Int
</span><a href="GHC.Types.Unique.html#getKey"><span class="hs-identifier hs-var">getKey</span></a></span><span> </span><span class="annot"><span class="annottext">(Unique -&gt; Int) -&gt; (Label -&gt; Unique) -&gt; Label -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span>
</span><span id="line-929"></span><span>
</span><span id="line-930"></span><span>    </span><span class="annot"><a href="#local-6989586621681020263"><span class="hs-identifier hs-type">toBlockId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-931"></span><span>    </span><span id="local-6989586621681020263"><span class="annot"><span class="annottext">toBlockId :: Int -&gt; Label
</span><a href="#local-6989586621681020263"><span class="hs-identifier hs-var hs-var">toBlockId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Label
</span><a href="GHC.Cmm.BlockId.html#mkBlockId"><span class="hs-identifier hs-var">mkBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">(Unique -&gt; Label) -&gt; (Int -&gt; Unique) -&gt; Int -&gt; Label
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkUniqueGrimily"><span class="hs-identifier hs-var">mkUniqueGrimily</span></a></span><span>
</span><span id="line-932"></span><span>
</span><span id="line-933"></span><span class="hs-comment">-- We make the CFG a Hoopl Graph, so we can reuse revPostOrder.</span><span>
</span><span id="line-934"></span><span class="hs-keyword">newtype</span><span> </span><span id="BlockNode"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BlockNode"><span class="hs-identifier hs-var">BlockNode</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681021526"><span class="annot"><a href="#local-6989586621681021526"><span class="hs-identifier hs-type">e</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#Extensibility"><span class="hs-identifier hs-type">Extensibility</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681021525"><span class="annot"><a href="#local-6989586621681021525"><span class="hs-identifier hs-type">x</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#Extensibility"><span class="hs-identifier hs-type">Extensibility</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BN"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BN"><span class="hs-identifier hs-var">BN</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-935"></span><span>
</span><span id="line-936"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Graph.html#NonLocal"><span class="hs-identifier hs-type">G.NonLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BlockNode"><span class="hs-identifier hs-type">BlockNode</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-937"></span><span>  </span><span id="local-6989586621681020199"><span class="annot"><span class="annottext">entryLabel :: forall (x :: Extensibility). BlockNode C x -&gt; Label
</span><a href="#local-6989586621681020199"><span class="hs-identifier hs-var hs-var hs-var hs-var">entryLabel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BN"><span class="hs-identifier hs-type">BN</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020198"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020198"><span class="hs-identifier hs-var">lbl</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Label]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020198"><span class="hs-identifier hs-var">lbl</span></a></span><span>
</span><span id="line-938"></span><span>  </span><span id="local-6989586621681020197"><span class="annot"><span class="annottext">successors :: forall (e :: Extensibility). BlockNode e C -&gt; [Label]
</span><a href="#local-6989586621681020197"><span class="hs-identifier hs-var hs-var hs-var hs-var">successors</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BN"><span class="hs-identifier hs-type">BN</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681020196"><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020196"><span class="hs-identifier hs-var">succs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020196"><span class="hs-identifier hs-var">succs</span></a></span><span>
</span><span id="line-939"></span><span>
</span><span id="line-940"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#revPostorderFrom"><span class="hs-identifier hs-type">revPostorderFrom</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-941"></span><span id="revPostorderFrom"><span class="annot"><span class="annottext">revPostorderFrom :: HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#revPostorderFrom"><span class="hs-identifier hs-var hs-var">revPostorderFrom</span></a></span></span><span> </span><span id="local-6989586621681020188"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020188"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020187"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020187"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-942"></span><span>    </span><span class="annot"><span class="annottext">(BlockNode C C -&gt; Label) -&gt; [BlockNode C C] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockNode C C -&gt; Label
</span><a href="#local-6989586621681020186"><span class="hs-identifier hs-var">fromNode</span></a></span><span> </span><span class="annot"><span class="annottext">([BlockNode C C] -&gt; [Label]) -&gt; [BlockNode C C] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (BlockNode C C) -&gt; Label -&gt; [BlockNode C C]
forall (block :: Extensibility -&gt; Extensibility -&gt; *).
NonLocal block =&gt;
LabelMap (block C C) -&gt; Label -&gt; [block C C]
</span><a href="GHC.Cmm.Dataflow.Graph.html#revPostorderFrom"><span class="hs-identifier hs-var">G.revPostorderFrom</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap (BlockNode C C)
</span><a href="#local-6989586621681020184"><span class="hs-identifier hs-var">hooplGraph</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020187"><span class="hs-identifier hs-var">root</span></a></span><span>
</span><span id="line-943"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-944"></span><span>    </span><span id="local-6989586621681020183"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020183"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020188"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-945"></span><span>    </span><span id="local-6989586621681020184"><span class="annot"><span class="annottext">hooplGraph :: LabelMap (BlockNode C C)
</span><a href="#local-6989586621681020184"><span class="hs-identifier hs-var hs-var">hooplGraph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LabelMap (BlockNode C C) -&gt; Label -&gt; LabelMap (BlockNode C C))
-&gt; LabelMap (BlockNode C C) -&gt; [Label] -&gt; LabelMap (BlockNode C C)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020182"><span class="annot"><span class="annottext">LabelMap (BlockNode C C)
</span><a href="#local-6989586621681020182"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020181"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020181"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
-&gt; BlockNode C C
-&gt; LabelMap (BlockNode C C)
-&gt; LabelMap (BlockNode C C)
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsert"><span class="hs-identifier hs-var">mapInsert</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020181"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; BlockNode C C
</span><a href="#local-6989586621681020180"><span class="hs-identifier hs-var">toNode</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020181"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap (BlockNode C C)
</span><a href="#local-6989586621681020182"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap (BlockNode C C)
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020183"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-946"></span><span>
</span><span id="line-947"></span><span>    </span><span class="annot"><a href="#local-6989586621681020186"><span class="hs-identifier hs-type">fromNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BlockNode"><span class="hs-identifier hs-type">BlockNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-948"></span><span>    </span><span id="local-6989586621681020186"><span class="annot"><span class="annottext">fromNode :: BlockNode C C -&gt; Label
</span><a href="#local-6989586621681020186"><span class="hs-identifier hs-var hs-var">fromNode</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BN"><span class="hs-identifier hs-type">BN</span></a></span><span> </span><span id="local-6989586621681020179"><span class="annot"><span class="annottext">(Label, [Label])
</span><a href="#local-6989586621681020179"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Label, [Label]) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, [Label])
</span><a href="#local-6989586621681020179"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-949"></span><span>
</span><span id="line-950"></span><span>    </span><span class="annot"><a href="#local-6989586621681020180"><span class="hs-identifier hs-type">toNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#BlockNode"><span class="hs-identifier hs-type">BlockNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span>
</span><span id="line-951"></span><span>    </span><span id="local-6989586621681020180"><span class="annot"><span class="annottext">toNode :: Label -&gt; BlockNode C C
</span><a href="#local-6989586621681020180"><span class="hs-identifier hs-var hs-var">toNode</span></a></span></span><span> </span><span id="local-6989586621681020178"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020178"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-952"></span><span>        </span><span class="annot"><span class="annottext">(Label, [Label]) -&gt; BlockNode C C
forall (e :: Extensibility) (x :: Extensibility).
(Label, [Label]) -&gt; BlockNode e x
</span><a href="GHC.CmmToAsm.CFG.html#BN"><span class="hs-identifier hs-var">BN</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020178"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessors"><span class="hs-identifier hs-var">getSuccessors</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020188"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; [Label]) -&gt; Label -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020178"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-953"></span><span>
</span><span id="line-954"></span><span>
</span><span id="line-955"></span><span class="hs-comment">-- | We take in a CFG which has on its edges weights which are</span><span>
</span><span id="line-956"></span><span class="hs-comment">--   relative only to other edges originating from the same node.</span><span>
</span><span id="line-957"></span><span class="hs-comment">--</span><span>
</span><span id="line-958"></span><span class="hs-comment">--   We return a CFG for which each edge represents a GLOBAL weight.</span><span>
</span><span id="line-959"></span><span class="hs-comment">--   This means edge weights are comparable across the whole graph.</span><span>
</span><span id="line-960"></span><span class="hs-comment">--</span><span>
</span><span id="line-961"></span><span class="hs-comment">--   For irreducible control flow results might be imprecise, otherwise they</span><span>
</span><span id="line-962"></span><span class="hs-comment">--   are reliable.</span><span>
</span><span id="line-963"></span><span class="hs-comment">--</span><span>
</span><span id="line-964"></span><span class="hs-comment">--   The algorithm is based on the Paper</span><span>
</span><span id="line-965"></span><span class="hs-comment">--   &quot;Static Branch Prediction and Program Profile Analysis&quot; by Y Wu, JR Larus</span><span>
</span><span id="line-966"></span><span class="hs-comment">--   The only big change is that we go over the nodes in the body of loops in</span><span>
</span><span id="line-967"></span><span class="hs-comment">--   reverse post order. Which is required for diamond control flow to work probably.</span><span>
</span><span id="line-968"></span><span class="hs-comment">--</span><span>
</span><span id="line-969"></span><span class="hs-comment">--   We also apply a few prediction heuristics (based on the same paper)</span><span>
</span><span id="line-970"></span><span class="hs-comment">--</span><span>
</span><span id="line-971"></span><span class="hs-comment">--   The returned result represents frequences.</span><span>
</span><span id="line-972"></span><span class="hs-comment">--   For blocks it's the expected number of executions and</span><span>
</span><span id="line-973"></span><span class="hs-comment">--   for edges is the number of traversals.</span><span>
</span><span id="line-974"></span><span>
</span><span id="line-975"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-pragma hs-type">mkGlobalWeights</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-976"></span><span class="hs-pragma">{-# SCC</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-pragma hs-type">mkGlobalWeights</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-977"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-identifier hs-type">mkGlobalWeights</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-978"></span><span id="mkGlobalWeights"><span class="annot"><span class="annottext">mkGlobalWeights :: HasDebugCallStack =&gt;
Label -&gt; CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double))
</span><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-identifier hs-var hs-var">mkGlobalWeights</span></a></span></span><span> </span><span id="local-6989586621681020147"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020147"><span class="hs-identifier hs-var">root</span></a></span></span><span> </span><span id="local-6989586621681020146"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020146"><span class="hs-identifier hs-var">localCfg</span></a></span></span><span>
</span><span id="line-979"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020146"><span class="hs-identifier hs-var">localCfg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (LabelMap Double, LabelMap (LabelMap Double))
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Error - Empty CFG&quot;</span></span><span>
</span><span id="line-980"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap Double
</span><a href="#local-6989586621681020145"><span class="hs-identifier hs-var">blockFreqs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LabelMap (LabelMap Double)
</span><a href="#local-6989586621681020144"><span class="hs-identifier hs-var">edgeFreqs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-982"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-983"></span><span>    </span><span class="hs-comment">-- Calculate fixpoints</span><span>
</span><span id="line-984"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681020143"><span class="annot"><span class="annottext">Array Int Double
</span><a href="#local-6989586621681020143"><span class="hs-identifier hs-var">blockFreqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020142"><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681020142"><span class="hs-identifier hs-var">edgeFreqs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
-&gt; [(Int, Int)]
-&gt; [(Int, [Int])]
-&gt; [Int]
-&gt; (Array Int Double, IntMap (IntMap Double))
</span><a href="GHC.CmmToAsm.CFG.html#calcFreqs"><span class="hs-identifier hs-var">calcFreqs</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681020140"><span class="hs-identifier hs-var">nodeProbs</span></a></span><span> </span><span class="annot"><span class="annottext">[(Int, Int)]
</span><a href="#local-6989586621681020139"><span class="hs-identifier hs-var">backEdges'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Int, [Int])]
</span><a href="#local-6989586621681020138"><span class="hs-identifier hs-var">bodies'</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681020137"><span class="hs-identifier hs-var">revOrder'</span></a></span><span>
</span><span id="line-985"></span><span>    </span><span id="local-6989586621681020145"><span class="annot"><span class="annottext">blockFreqs' :: LabelMap Double
</span><a href="#local-6989586621681020145"><span class="hs-identifier hs-var hs-var">blockFreqs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Double)] -&gt; LabelMap Double
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, Double)] -&gt; LabelMap Double)
-&gt; [(KeyOf LabelMap, Double)] -&gt; LabelMap Double
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Int, Double) -&gt; (Label, Double))
-&gt; [(Int, Double)] -&gt; [(Label, Double)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int -&gt; Label) -&gt; (Int, Double) -&gt; (Label, Double)
forall (p :: * -&gt; * -&gt; *) a b c.
Bifunctor p =&gt;
(a -&gt; b) -&gt; p a c -&gt; p b c
</span><a href="../../base/src/Data.Bifunctor.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Label
</span><a href="#local-6989586621681020136"><span class="hs-identifier hs-var">fromVertex</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array Int Double -&gt; [(Int, Double)]
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
a i e -&gt; [(i, e)]
</span><a href="../../array/src/Data.Array.Base.html#assocs"><span class="hs-identifier hs-var">assocs</span></a></span><span> </span><span class="annot"><span class="annottext">Array Int Double
</span><a href="#local-6989586621681020143"><span class="hs-identifier hs-var">blockFreqs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span>
</span><span id="line-986"></span><span>    </span><span id="local-6989586621681020144"><span class="annot"><span class="annottext">edgeFreqs' :: LabelMap (LabelMap Double)
</span><a href="#local-6989586621681020144"><span class="hs-identifier hs-var hs-var">edgeFreqs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap Double -&gt; LabelMap Double)
-&gt; LabelMap (IntMap Double) -&gt; LabelMap (LabelMap Double)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Double -&gt; LabelMap Double
forall x. IntMap x -&gt; LabelMap x
</span><a href="#local-6989586621681020134"><span class="hs-identifier hs-var">fromVertexMap</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap (IntMap Double) -&gt; LabelMap (LabelMap Double))
-&gt; LabelMap (IntMap Double) -&gt; LabelMap (LabelMap Double)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double) -&gt; LabelMap (IntMap Double)
forall x. IntMap x -&gt; LabelMap x
</span><a href="#local-6989586621681020134"><span class="hs-identifier hs-var">fromVertexMap</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681020142"><span class="hs-identifier hs-var">edgeFreqs</span></a></span><span>
</span><span id="line-987"></span><span>
</span><span id="line-988"></span><span>    </span><span id="local-6989586621681021518"><span class="annot"><a href="#local-6989586621681020134"><span class="hs-identifier hs-type">fromVertexMap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021518"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681021518"><span class="hs-identifier hs-type">x</span></a></span></span><span>
</span><span id="line-989"></span><span>    </span><span id="local-6989586621681020134"><span class="annot"><span class="annottext">fromVertexMap :: forall x. IntMap x -&gt; LabelMap x
</span><a href="#local-6989586621681020134"><span class="hs-identifier hs-var hs-var">fromVertexMap</span></a></span></span><span> </span><span id="local-6989586621681020131"><span class="annot"><span class="annottext">IntMap x
</span><a href="#local-6989586621681020131"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Label, x)] -&gt; LabelMap x
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(Label, x)] -&gt; LabelMap x)
-&gt; ([(Int, x)] -&gt; [(Label, x)]) -&gt; [(Int, x)] -&gt; LabelMap x
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((Int, x) -&gt; (Label, x)) -&gt; [(Int, x)] -&gt; [(Label, x)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int -&gt; Label) -&gt; (Int, x) -&gt; (Label, x)
forall (p :: * -&gt; * -&gt; *) a b c.
Bifunctor p =&gt;
(a -&gt; b) -&gt; p a c -&gt; p b c
</span><a href="../../base/src/Data.Bifunctor.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Label
</span><a href="#local-6989586621681020136"><span class="hs-identifier hs-var">fromVertex</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([(Int, x)] -&gt; LabelMap x) -&gt; [(Int, x)] -&gt; LabelMap x
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap x -&gt; [(Int, x)]
forall a. IntMap a -&gt; [(Int, a)]
</span><a href="../../containers/src/Data.IntMap.Internal.html#toList"><span class="hs-identifier hs-var">IM.toList</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap x
</span><a href="#local-6989586621681020131"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-990"></span><span>
</span><span id="line-991"></span><span>    </span><span id="local-6989586621681020129"><span class="annot"><span class="annottext">revOrder :: [Label]
</span><a href="#local-6989586621681020129"><span class="hs-identifier hs-var hs-var">revOrder</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [Label]
CFG -&gt; Label -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#revPostorderFrom"><span class="hs-identifier hs-var">revPostorderFrom</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020146"><span class="hs-identifier hs-var">localCfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020147"><span class="hs-identifier hs-var">root</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-992"></span><span>    </span><span id="local-6989586621681020128"><span class="annot"><span class="annottext">loopResults :: LoopInfo
</span><a href="#local-6989586621681020128"><span class="hs-identifier hs-var">loopResults</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span> </span><span id="local-6989586621681020127"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020127"><span class="hs-identifier hs-var">backedges</span></a></span></span><span> </span><span id="local-6989586621681020126"><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020126"><span class="hs-identifier hs-var">_levels</span></a></span></span><span> </span><span id="local-6989586621681020125"><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020125"><span class="hs-identifier hs-var">bodies</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; LoopInfo
CFG -&gt; Label -&gt; LoopInfo
</span><a href="GHC.CmmToAsm.CFG.html#loopInfo"><span class="hs-identifier hs-var">loopInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020146"><span class="hs-identifier hs-var">localCfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020147"><span class="hs-identifier hs-var">root</span></a></span><span>
</span><span id="line-993"></span><span>
</span><span id="line-994"></span><span>    </span><span id="local-6989586621681020137"><span class="annot"><span class="annottext">revOrder' :: [Int]
</span><a href="#local-6989586621681020137"><span class="hs-identifier hs-var hs-var">revOrder'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Int) -&gt; [Label] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020129"><span class="hs-identifier hs-var">revOrder</span></a></span><span>
</span><span id="line-995"></span><span>    </span><span id="local-6989586621681020139"><span class="annot"><span class="annottext">backEdges' :: [(Int, Int)]
</span><a href="#local-6989586621681020139"><span class="hs-identifier hs-var hs-var">backEdges'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Edge -&gt; (Int, Int)) -&gt; [Edge] -&gt; [(Int, Int)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Label -&gt; Int) -&gt; (Label -&gt; Int) -&gt; Edge -&gt; (Int, Int)
forall (p :: * -&gt; * -&gt; *) a b c d.
Bifunctor p =&gt;
(a -&gt; b) -&gt; (c -&gt; d) -&gt; p a c -&gt; p b d
</span><a href="../../base/src/Data.Bifunctor.html#bimap"><span class="hs-identifier hs-var">bimap</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020127"><span class="hs-identifier hs-var">backedges</span></a></span><span>
</span><span id="line-996"></span><span>    </span><span id="local-6989586621681020138"><span class="annot"><span class="annottext">bodies' :: [(Int, [Int])]
</span><a href="#local-6989586621681020138"><span class="hs-identifier hs-var hs-var">bodies'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Edge, LabelSet) -&gt; (Int, [Int]))
-&gt; [(Edge, LabelSet)] -&gt; [(Int, [Int])]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Edge, LabelSet) -&gt; (Int, [Int])
forall {set} {a}.
(IsSet set, ElemOf set ~ Label) =&gt;
((a, Label), set) -&gt; (Int, [Int])
</span><a href="#local-6989586621681020122"><span class="hs-identifier hs-var">calcBody</span></a></span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020125"><span class="hs-identifier hs-var">bodies</span></a></span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span>    </span><span id="local-6989586621681020121"><span class="annot"><span class="annottext">estimatedCfg :: CFG
</span><a href="#local-6989586621681020121"><span class="hs-identifier hs-var hs-var">estimatedCfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Label -&gt; LoopInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#staticBranchPrediction"><span class="hs-identifier hs-var">staticBranchPrediction</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020147"><span class="hs-identifier hs-var">root</span></a></span><span> </span><span class="annot"><span class="annottext">LoopInfo
</span><a href="#local-6989586621681020128"><span class="hs-identifier hs-var">loopResults</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020146"><span class="hs-identifier hs-var">localCfg</span></a></span><span>
</span><span id="line-999"></span><span>    </span><span class="hs-comment">-- Normalize the weights to probabilities and apply heuristics</span><span>
</span><span id="line-1000"></span><span>    </span><span id="local-6989586621681020140"><span class="annot"><span class="annottext">nodeProbs :: IntMap (IntMap Double)
</span><a href="#local-6989586621681020140"><span class="hs-identifier hs-var hs-var">nodeProbs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; (Label -&gt; Int) -&gt; IntMap (IntMap Double)
</span><a href="GHC.CmmToAsm.CFG.html#cfgEdgeProbabilities"><span class="hs-identifier hs-var">cfgEdgeProbabilities</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020121"><span class="hs-identifier hs-var">estimatedCfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span>
</span><span id="line-1001"></span><span>
</span><span id="line-1002"></span><span>    </span><span class="hs-comment">-- By mapping vertices to numbers in reverse post order we can bring any subset into reverse post</span><span>
</span><span id="line-1003"></span><span>    </span><span class="hs-comment">-- order simply by sorting.</span><span>
</span><span id="line-1004"></span><span>    </span><span class="hs-comment">-- TODO: The sort is redundant if we can guarantee that setElems returns elements ascending</span><span>
</span><span id="line-1005"></span><span>    </span><span id="local-6989586621681020122"><span class="annot"><span class="annottext">calcBody :: ((a, Label), set) -&gt; (Int, [Int])
</span><a href="#local-6989586621681020122"><span class="hs-identifier hs-var hs-var">calcBody</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020111"><span class="annot"><span class="annottext">(a, Label)
</span><a href="#local-6989586621681020111"><span class="hs-identifier hs-var">backedge</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681020110"><span class="annot"><span class="annottext">set
</span><a href="#local-6989586621681020110"><span class="hs-identifier hs-var">blocks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1006"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Int) -&gt; Label -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(a, Label) -&gt; Label
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(a, Label)
</span><a href="#local-6989586621681020111"><span class="hs-identifier hs-var">backedge</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Int] -&gt; [Int]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">([Int] -&gt; [Int]) -&gt; ([Label] -&gt; [Int]) -&gt; [Label] -&gt; [Int]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label -&gt; Int) -&gt; [Label] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; [Int]) -&gt; [Label] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">set -&gt; [ElemOf set]
forall set. IsSet set =&gt; set -&gt; [ElemOf set]
</span><a href="GHC.Cmm.Dataflow.Collections.html#setElems"><span class="hs-identifier hs-var">setElems</span></a></span><span> </span><span class="annot"><span class="annottext">set
</span><a href="#local-6989586621681020110"><span class="hs-identifier hs-var">blocks</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1007"></span><span>
</span><span id="line-1008"></span><span>    </span><span id="local-6989586621681020109"><span class="annot"><span class="annottext">vertexMapping :: LabelMap Int
</span><a href="#local-6989586621681020109"><span class="hs-identifier hs-var hs-var">vertexMapping</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Int)] -&gt; LabelMap Int
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(KeyOf LabelMap, Int)] -&gt; LabelMap Int)
-&gt; [(KeyOf LabelMap, Int)] -&gt; LabelMap Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [Int] -&gt; [(Label, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020129"><span class="hs-identifier hs-var">revOrder</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1009"></span><span>    </span><span id="local-6989586621681020108"><span class="annot"><span class="annottext">blockMapping :: Array Int Label
</span><a href="#local-6989586621681020108"><span class="hs-identifier hs-var hs-var">blockMapping</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, Int) -&gt; [Label] -&gt; Array Int Label
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
(i, i) -&gt; [e] -&gt; a i e
</span><a href="../../array/src/Data.Array.Base.html#listArray"><span class="hs-identifier hs-var">listArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">LabelMap Int -&gt; Int
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; Int
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapSize"><span class="hs-identifier hs-var">mapSize</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020109"><span class="hs-identifier hs-var">vertexMapping</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020129"><span class="hs-identifier hs-var">revOrder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Arr.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-1010"></span><span>    </span><span class="hs-comment">-- Map from blockId to indices starting at zero</span><span>
</span><span id="line-1011"></span><span>    </span><span class="annot"><a href="#local-6989586621681020124"><span class="hs-identifier hs-type">toVertex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1012"></span><span>    </span><span id="local-6989586621681020124"><span class="annot"><span class="annottext">toVertex :: Label -&gt; Int
</span><a href="#local-6989586621681020124"><span class="hs-identifier hs-var hs-var">toVertex</span></a></span></span><span>   </span><span id="local-6989586621681020105"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020105"><span class="hs-identifier hs-var">blockId</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe Int -&gt; Int
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mkGlobalWeights&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe Int -&gt; Int) -&gt; Maybe Int -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Int -&gt; Maybe Int
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020105"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020109"><span class="hs-identifier hs-var">vertexMapping</span></a></span><span>
</span><span id="line-1013"></span><span>    </span><span class="hs-comment">-- Map from indices starting at zero to blockIds</span><span>
</span><span id="line-1014"></span><span>    </span><span class="annot"><a href="#local-6989586621681020136"><span class="hs-identifier hs-type">fromVertex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-1015"></span><span>    </span><span id="local-6989586621681020136"><span class="annot"><span class="annottext">fromVertex :: Int -&gt; Label
</span><a href="#local-6989586621681020136"><span class="hs-identifier hs-var hs-var">fromVertex</span></a></span></span><span> </span><span id="local-6989586621681020104"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020104"><span class="hs-identifier hs-var">vertex</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array Int Label
</span><a href="#local-6989586621681020108"><span class="hs-identifier hs-var">blockMapping</span></a></span><span> </span><span class="annot"><span class="annottext">Array Int Label -&gt; Int -&gt; Label
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
a i e -&gt; i -&gt; e
</span><a href="../../array/src/Data.Array.Base.html#%21"><span class="hs-operator hs-var">!</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681020104"><span class="hs-identifier hs-var">vertex</span></a></span><span>
</span><span id="line-1016"></span><span>
</span><span id="line-1017"></span><span class="hs-comment">{- Note [Static Branch Prediction]
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The work here has been based on the paper
&quot;Static Branch Prediction and Program Profile Analysis&quot; by Y Wu, JR Larus.

The primary differences are that if we branch on the result of a heap
check we do not apply any of the heuristics.
The reason is simple: They look like loops in the control flow graph
but are usually never entered, and if at most once.

Currently implemented is a heuristic to predict that we do not exit
loops (lehPredicts) and one to predict that backedges are more likely
than any other edge.

The back edge case is special as it superceeds any other heuristic if it
applies.

Do NOT rely solely on nofib results for benchmarking this. I recommend at least
comparing megaparsec and container benchmarks. Nofib does not seeem to have
many instances of &quot;loopy&quot; Cmm where these make a difference.

TODO:
* The paper containers more benchmarks which should be implemented.
* If we turn the likelihood on if/else branches into a probability
  instead of true/false we could implement this as a Cmm pass.
  + The complete Cmm code still exists and can be accessed by the heuristics
  + There is no chance of register allocation/codegen inserting branches/blocks
  + making the TransitionSource info wrong.
  + potential to use this information in CmmPasses.
  - Requires refactoring of all the code relying on the binary nature of likelihood.
  - Requires refactoring `loopInfo` to work on both, Cmm Graphs and the backend CFG.
-}</span><span>
</span><span id="line-1050"></span><span>
</span><span id="line-1051"></span><span class="hs-comment">-- | Combination of target node id and information about the branch</span><span>
</span><span id="line-1052"></span><span class="hs-comment">--   we are looking at.</span><span>
</span><span id="line-1053"></span><span class="hs-keyword">type</span><span> </span><span id="TargetNodeInfo"><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TargetNodeInfo"><span class="hs-identifier hs-var">TargetNodeInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1054"></span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span class="hs-comment">-- | Update branch weights based on certain heuristics.</span><span>
</span><span id="line-1057"></span><span class="hs-comment">-- See Note [Static Branch Prediction]</span><span>
</span><span id="line-1058"></span><span class="hs-comment">-- TODO: This should be combined with optimizeCFG</span><span>
</span><span id="line-1059"></span><span class="hs-pragma">{-# SCC</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#staticBranchPrediction"><span class="hs-pragma hs-type">staticBranchPrediction</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-1060"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#staticBranchPrediction"><span class="hs-identifier hs-type">staticBranchPrediction</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-1061"></span><span id="staticBranchPrediction"><span class="annot"><span class="annottext">staticBranchPrediction :: Label -&gt; LoopInfo -&gt; CFG -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#staticBranchPrediction"><span class="hs-identifier hs-var hs-var">staticBranchPrediction</span></a></span></span><span> </span><span id="local-6989586621681020101"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020101"><span class="hs-identifier hs-var">_root</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#LoopInfo"><span class="hs-identifier hs-type">LoopInfo</span></a></span><span> </span><span id="local-6989586621681020100"><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020100"><span class="hs-identifier hs-var">l_backEdges</span></a></span></span><span> </span><span id="local-6989586621681020099"><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020099"><span class="hs-identifier hs-var">loopLevels</span></a></span></span><span> </span><span id="local-6989586621681020098"><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020098"><span class="hs-identifier hs-var">l_loops</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681020097"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020097"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1062"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;staticEstimatesOn&quot; (ppr (cfg)) $</span><span>
</span><span id="line-1063"></span><span>    </span><span class="annot"><span class="annottext">(CFG -&gt; Label -&gt; CFG) -&gt; CFG -&gt; [Label] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020096"><span class="hs-identifier hs-var">update</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020097"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">[Label]
</span><a href="#local-6989586621681020095"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-1064"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1065"></span><span>    </span><span id="local-6989586621681020095"><span class="annot"><span class="annottext">nodes :: [Label]
</span><a href="#local-6989586621681020095"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; [Label]
</span><a href="GHC.CmmToAsm.CFG.html#getCfgNodes"><span class="hs-identifier hs-var">getCfgNodes</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020097"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1066"></span><span>    </span><span id="local-6989586621681020094"><span class="annot"><span class="annottext">backedges :: Set Edge
</span><a href="#local-6989586621681020094"><span class="hs-identifier hs-var hs-var">backedges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Edge] -&gt; Set Edge
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">S.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([Edge] -&gt; Set Edge) -&gt; [Edge] -&gt; Set Edge
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Edge]
</span><a href="#local-6989586621681020100"><span class="hs-identifier hs-var">l_backEdges</span></a></span><span>
</span><span id="line-1067"></span><span>    </span><span class="hs-comment">-- Loops keyed by their back edge</span><span>
</span><span id="line-1068"></span><span>    </span><span id="local-6989586621681020092"><span class="annot"><span class="annottext">loops :: Map Edge LabelSet
</span><a href="#local-6989586621681020092"><span class="hs-identifier hs-var hs-var">loops</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)] -&gt; Map Edge LabelSet
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#fromList"><span class="hs-identifier hs-var">M.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(Edge, LabelSet)] -&gt; Map Edge LabelSet)
-&gt; [(Edge, LabelSet)] -&gt; Map Edge LabelSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(Edge, LabelSet)]
</span><a href="#local-6989586621681020098"><span class="hs-identifier hs-var">l_loops</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">M.Map</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Edge"><span class="hs-identifier hs-type">Edge</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelSet"><span class="hs-identifier hs-type">LabelSet</span></a></span><span>
</span><span id="line-1069"></span><span>    </span><span id="local-6989586621681020090"><span class="annot"><span class="annottext">loopHeads :: Set Label
</span><a href="#local-6989586621681020090"><span class="hs-identifier hs-var hs-var">loopHeads</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; Set Label
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">S.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([Label] -&gt; Set Label) -&gt; [Label] -&gt; Set Label
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Edge -&gt; Label) -&gt; [Edge] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Edge -&gt; Label
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">([Edge] -&gt; [Label]) -&gt; [Edge] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Map Edge LabelSet -&gt; [Edge]
forall k a. Map k a -&gt; [k]
</span><a href="../../containers/src/Data.Map.Internal.html#keys"><span class="hs-identifier hs-var">M.keys</span></a></span><span> </span><span class="annot"><span class="annottext">Map Edge LabelSet
</span><a href="#local-6989586621681020092"><span class="hs-identifier hs-var">loops</span></a></span><span>
</span><span id="line-1070"></span><span>
</span><span id="line-1071"></span><span>    </span><span class="annot"><a href="#local-6989586621681020096"><span class="hs-identifier hs-type">update</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-1072"></span><span>    </span><span id="local-6989586621681020096"><span class="annot"><span class="annottext">update :: CFG -&gt; Label -&gt; CFG
</span><a href="#local-6989586621681020096"><span class="hs-identifier hs-var hs-var">update</span></a></span></span><span> </span><span id="local-6989586621681020088"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020087"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span></span><span>
</span><span id="line-1073"></span><span>        </span><span class="hs-comment">-- No successors, nothing to do.</span><span>
</span><span id="line-1074"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1075"></span><span>
</span><span id="line-1076"></span><span>        </span><span class="hs-comment">-- Mix of backedges and others:</span><span>
</span><span id="line-1077"></span><span>        </span><span class="hs-comment">-- Always predict the backedges.</span><span>
</span><span id="line-1078"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-1079"></span><span>        </span><span class="hs-comment">-- Heap/Stack checks &quot;loop&quot;, but only once.</span><span>
</span><span id="line-1080"></span><span>        </span><span class="hs-comment">-- So we simply exclude any case involving them.</span><span>
</span><span id="line-1081"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Bool) -&gt; [(Label, EdgeInfo)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TransitionSource -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var">isHeapOrStackCheck</span></a></span><span>  </span><span class="annot"><span class="annottext">(TransitionSource -&gt; Bool)
-&gt; ((Label, EdgeInfo) -&gt; TransitionSource)
-&gt; (Label, EdgeInfo)
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; TransitionSource)
-&gt; ((Label, EdgeInfo) -&gt; EdgeInfo)
-&gt; (Label, EdgeInfo)
-&gt; TransitionSource
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; EdgeInfo
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-1082"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>   </span><span id="local-6989586621681020084"><span class="annot"><span class="annottext">loopChance :: [EdgeWeight]
</span><a href="#local-6989586621681020084"><span class="hs-identifier hs-var hs-var">loopChance</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; [EdgeWeight]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; [EdgeWeight]) -&gt; EdgeWeight -&gt; [EdgeWeight]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020083"><span class="hs-identifier hs-var">pred_LBH</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; EdgeWeight) -&gt; Int -&gt; EdgeWeight
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1083"></span><span>                </span><span id="local-6989586621681020081"><span class="annot"><span class="annottext">exitChance :: [EdgeWeight]
</span><a href="#local-6989586621681020081"><span class="hs-identifier hs-var hs-var">exitChance</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; [EdgeWeight]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; [EdgeWeight]) -&gt; EdgeWeight -&gt; [EdgeWeight]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020083"><span class="hs-identifier hs-var">pred_LBH</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; EdgeWeight
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020080"><span class="hs-identifier hs-var">not_m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1084"></span><span>                </span><span id="local-6989586621681020079"><span class="annot"><span class="annottext">updates :: [(Label, EdgeWeight)]
</span><a href="#local-6989586621681020079"><span class="hs-identifier hs-var hs-var">updates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [EdgeWeight] -&gt; [(Label, EdgeWeight)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Label) -&gt; [(Label, EdgeInfo)] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EdgeWeight]
</span><a href="#local-6989586621681020084"><span class="hs-identifier hs-var">loopChance</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeWeight)]
-&gt; [(Label, EdgeWeight)] -&gt; [(Label, EdgeWeight)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Label] -&gt; [EdgeWeight] -&gt; [(Label, EdgeWeight)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Label) -&gt; [(Label, EdgeInfo)] -&gt; [Label]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020080"><span class="hs-identifier hs-var">not_m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EdgeWeight]
</span><a href="#local-6989586621681020081"><span class="hs-identifier hs-var">exitChance</span></a></span><span>
</span><span id="line-1085"></span><span>        </span><span class="hs-keyword">in</span><span>  </span><span class="hs-comment">-- pprTrace &quot;mix&quot; (ppr (node,successors)) $</span><span>
</span><span id="line-1086"></span><span>            </span><span class="annot"><span class="annottext">(CFG -&gt; (Label, EdgeWeight) -&gt; CFG)
-&gt; CFG -&gt; [(Label, EdgeWeight)] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020078"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020078"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020077"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020077"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020076"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020076"><span class="hs-identifier hs-var">weight</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020078"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020076"><span class="hs-identifier hs-var">weight</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020077"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeWeight)]
</span><a href="#local-6989586621681020079"><span class="hs-identifier hs-var">updates</span></a></span><span>
</span><span id="line-1087"></span><span>
</span><span id="line-1088"></span><span>        </span><span class="hs-comment">-- For (regular) non-binary branches we keep the weights from the STG -&gt; Cmm translation.</span><span>
</span><span id="line-1089"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>
</span><span id="line-1090"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1091"></span><span>
</span><span id="line-1092"></span><span>        </span><span class="hs-comment">-- Only backedges - no need to adjust</span><span>
</span><span id="line-1093"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1094"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1095"></span><span>
</span><span id="line-1096"></span><span>        </span><span class="hs-comment">-- A regular binary branch, we can plug addition predictors in here.</span><span>
</span><span id="line-1097"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621681020074"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020074"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020073"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020073"><span class="hs-identifier hs-var">s1_info</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span id="local-6989586621681020072"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020072"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020071"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020071"><span class="hs-identifier hs-var">s2_info</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-1098"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Bool) -&gt; [(Label, EdgeInfo)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TransitionSource -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var">isHeapOrStackCheck</span></a></span><span>  </span><span class="annot"><span class="annottext">(TransitionSource -&gt; Bool)
-&gt; ((Label, EdgeInfo) -&gt; TransitionSource)
-&gt; (Label, EdgeInfo)
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; TransitionSource)
-&gt; ((Label, EdgeInfo) -&gt; EdgeInfo)
-&gt; (Label, EdgeInfo)
-&gt; TransitionSource
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; EdgeInfo
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-1099"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- Normalize weights to total of 1</span><span>
</span><span id="line-1100"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681020070"><span class="annot"><span class="annottext">w1 :: EdgeWeight
</span><a href="#local-6989586621681020070"><span class="hs-identifier hs-var hs-var">w1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020073"><span class="hs-identifier hs-var">s1_info</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-1101"></span><span>                </span><span class="hs-glyph">!</span><span id="local-6989586621681020068"><span class="annot"><span class="annottext">w2 :: EdgeWeight
</span><a href="#local-6989586621681020068"><span class="hs-identifier hs-var hs-var">w2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020071"><span class="hs-identifier hs-var">s2_info</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-1102"></span><span>                </span><span class="hs-comment">-- Of both weights are &lt;= 0 we set both to 0.5</span><span>
</span><span id="line-1103"></span><span>                </span><span id="local-6989586621681020067"><span class="annot"><span class="annottext">normalizeWeight :: EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020067"><span class="hs-identifier hs-var hs-var">normalizeWeight</span></a></span></span><span> </span><span id="local-6989586621681020066"><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020066"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020070"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020068"><span class="hs-identifier hs-var">w2</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0.5</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020066"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020070"><span class="hs-identifier hs-var">w1</span></a></span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020068"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1104"></span><span>                </span><span class="hs-glyph">!</span><span id="local-6989586621681020065"><span class="annot"><span class="annottext">cfg' :: CFG
</span><a href="#local-6989586621681020065"><span class="hs-identifier hs-var hs-var">cfg'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020067"><span class="hs-identifier hs-var">normalizeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020070"><span class="hs-identifier hs-var">w1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020074"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-1105"></span><span>                </span><span class="hs-glyph">!</span><span id="local-6989586621681020064"><span class="annot"><span class="annottext">cfg'' :: CFG
</span><a href="#local-6989586621681020064"><span class="hs-identifier hs-var hs-var">cfg''</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020065"><span class="hs-identifier hs-var">cfg'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight
</span><a href="#local-6989586621681020067"><span class="hs-identifier hs-var">normalizeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020068"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020072"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1106"></span><span>
</span><span id="line-1107"></span><span>                </span><span class="hs-comment">-- Figure out which heuristics apply to these successors</span><span>
</span><span id="line-1108"></span><span>                </span><span id="local-6989586621681020063"><span class="annot"><span class="annottext">heuristics :: [Maybe Double]
</span><a href="#local-6989586621681020063"><span class="hs-identifier hs-var hs-var">heuristics</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double)
 -&gt; Maybe Double)
-&gt; [((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double]
-&gt; [Maybe Double]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double)
-&gt; ((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020074"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020073"><span class="hs-identifier hs-var">s1_info</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020072"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020071"><span class="hs-identifier hs-var">s2_info</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1109"></span><span>                            </span><span class="hs-special">[</span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
</span><a href="#local-6989586621681020062"><span class="hs-identifier hs-var">lehPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020061"><span class="hs-identifier hs-var">phPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
</span><a href="#local-6989586621681020060"><span class="hs-identifier hs-var">ohPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020059"><span class="hs-identifier hs-var">ghPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020058"><span class="hs-identifier hs-var">lhhPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020057"><span class="hs-identifier hs-var">chPredicts</span></a></span><span>
</span><span id="line-1110"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020056"><span class="hs-identifier hs-var">shPredicts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
forall {b} {a}. b -&gt; Maybe a
</span><a href="#local-6989586621681020055"><span class="hs-identifier hs-var">rhPredicts</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1111"></span><span>                </span><span class="hs-comment">-- Apply result of a heuristic. Argument is the likelihood</span><span>
</span><span id="line-1112"></span><span>                </span><span class="hs-comment">-- predicted for s1.</span><span>
</span><span id="line-1113"></span><span>                </span><span class="annot"><a href="#local-6989586621681020054"><span class="hs-identifier hs-type">applyHeuristic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-1114"></span><span>                </span><span id="local-6989586621681020054"><span class="annot"><span class="annottext">applyHeuristic :: CFG -&gt; Maybe Double -&gt; CFG
</span><a href="#local-6989586621681020054"><span class="hs-identifier hs-var hs-var">applyHeuristic</span></a></span></span><span> </span><span id="local-6989586621681020053"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020053"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Double
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020053"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1115"></span><span>                </span><span class="annot"><a href="#local-6989586621681020054"><span class="hs-identifier hs-var">applyHeuristic</span></a></span><span> </span><span id="local-6989586621681020052"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020052"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020051"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020051"><span class="hs-identifier hs-var">s1_pred</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1116"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020050"><span class="hs-identifier hs-var">s1_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020049"><span class="hs-identifier hs-var">s2_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-1117"></span><span>                    </span><span class="annot"><span class="annottext">TransitionSource -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var">isHeapOrStackCheck</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020073"><span class="hs-identifier hs-var">s1_info</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-1118"></span><span>                    </span><span class="annot"><span class="annottext">TransitionSource -&gt; Bool
</span><a href="GHC.CmmToAsm.CFG.html#isHeapOrStackCheck"><span class="hs-identifier hs-var">isHeapOrStackCheck</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeInfo -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#transitionSource"><span class="hs-identifier hs-var hs-var">transitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020071"><span class="hs-identifier hs-var">s2_info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1119"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020052"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1120"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1121"></span><span>                    </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- Predictions from heuristic</span><span>
</span><span id="line-1122"></span><span>                        </span><span id="local-6989586621681020048"><span class="annot"><span class="annottext">s1_prob :: EdgeWeight
</span><a href="#local-6989586621681020048"><span class="hs-identifier hs-var hs-var">s1_prob</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-var">EdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020051"><span class="hs-identifier hs-var">s1_pred</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-1123"></span><span>                        </span><span id="local-6989586621681020047"><span class="annot"><span class="annottext">s2_prob :: EdgeWeight
</span><a href="#local-6989586621681020047"><span class="hs-identifier hs-var hs-var">s2_prob</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">1.0</span></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020048"><span class="hs-identifier hs-var">s1_prob</span></a></span><span>
</span><span id="line-1124"></span><span>                        </span><span class="hs-comment">-- Update</span><span>
</span><span id="line-1125"></span><span>                        </span><span id="local-6989586621681020046"><span class="annot"><span class="annottext">d :: EdgeWeight
</span><a href="#local-6989586621681020046"><span class="hs-identifier hs-var hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020050"><span class="hs-identifier hs-var">s1_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020048"><span class="hs-identifier hs-var">s1_prob</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020049"><span class="hs-identifier hs-var">s2_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020047"><span class="hs-identifier hs-var">s2_prob</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeWeight"><span class="hs-identifier hs-type">EdgeWeight</span></a></span><span>
</span><span id="line-1126"></span><span>                        </span><span id="local-6989586621681020044"><span class="annot"><span class="annottext">s1_prob' :: EdgeWeight
</span><a href="#local-6989586621681020044"><span class="hs-identifier hs-var hs-var">s1_prob'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020050"><span class="hs-identifier hs-var">s1_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020048"><span class="hs-identifier hs-var">s1_prob</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020046"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-1127"></span><span>                        </span><span class="hs-glyph">!</span><span id="local-6989586621681020043"><span class="annot"><span class="annottext">s2_prob' :: EdgeWeight
</span><a href="#local-6989586621681020043"><span class="hs-identifier hs-var hs-var">s2_prob'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020049"><span class="hs-identifier hs-var">s2_old</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020047"><span class="hs-identifier hs-var">s2_prob</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight -&gt; EdgeWeight -&gt; EdgeWeight
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020046"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-1128"></span><span>                        </span><span class="hs-glyph">!</span><span id="local-6989586621681020042"><span class="annot"><span class="annottext">cfg_s1 :: CFG
</span><a href="#local-6989586621681020042"><span class="hs-identifier hs-var hs-var">cfg_s1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020052"><span class="hs-identifier hs-var">cfg</span></a></span><span>    </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020044"><span class="hs-identifier hs-var">s1_prob'</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020074"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-1129"></span><span>                    </span><span class="hs-keyword">in</span><span>  </span><span class="hs-comment">-- pprTrace &quot;Applying heuristic!&quot; (ppr (node,s1,s2) $$ ppr (s1_prob', s2_prob')) $</span><span>
</span><span id="line-1130"></span><span>                        </span><span class="annot"><span class="annottext">CFG -&gt; EdgeWeight -&gt; Label -&gt; Label -&gt; CFG
</span><a href="GHC.CmmToAsm.CFG.html#setEdgeWeight"><span class="hs-identifier hs-var">setEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020042"><span class="hs-identifier hs-var">cfg_s1</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><a href="#local-6989586621681020043"><span class="hs-identifier hs-var">s2_prob'</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020072"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1131"></span><span>                  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1132"></span><span>                    </span><span class="hs-comment">-- Old weights</span><span>
</span><span id="line-1133"></span><span>                    </span><span id="local-6989586621681020050"><span class="annot"><span class="annottext">s1_old :: EdgeWeight
</span><a href="#local-6989586621681020050"><span class="hs-identifier hs-var hs-var">s1_old</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; Label -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeWeight"><span class="hs-identifier hs-var">getEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020052"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020074"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-1134"></span><span>                    </span><span id="local-6989586621681020049"><span class="annot"><span class="annottext">s2_old :: EdgeWeight
</span><a href="#local-6989586621681020049"><span class="hs-identifier hs-var hs-var">s2_old</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Label -&gt; Label -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#getEdgeWeight"><span class="hs-identifier hs-var">getEdgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020052"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020072"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1135"></span><span>
</span><span id="line-1136"></span><span>            </span><span class="hs-keyword">in</span><span>
</span><span id="line-1137"></span><span>            </span><span class="hs-comment">-- pprTraceIt &quot;RegularCfgResult&quot; $</span><span>
</span><span id="line-1138"></span><span>            </span><span class="annot"><span class="annottext">(CFG -&gt; Maybe Double -&gt; CFG) -&gt; CFG -&gt; [Maybe Double] -&gt; CFG
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CFG -&gt; Maybe Double -&gt; CFG
</span><a href="#local-6989586621681020054"><span class="hs-identifier hs-var">applyHeuristic</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020064"><span class="hs-identifier hs-var">cfg''</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Double]
</span><a href="#local-6989586621681020063"><span class="hs-identifier hs-var">heuristics</span></a></span><span>
</span><span id="line-1139"></span><span>
</span><span id="line-1140"></span><span>        </span><span class="hs-comment">-- Branch on heap/stack check</span><span>
</span><span id="line-1141"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1142"></span><span>
</span><span id="line-1143"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1144"></span><span>        </span><span class="hs-comment">-- Chance that loops are taken.</span><span>
</span><span id="line-1145"></span><span>        </span><span id="local-6989586621681020083"><span class="annot"><span class="annottext">pred_LBH :: EdgeWeight
</span><a href="#local-6989586621681020083"><span class="hs-identifier hs-var hs-var">pred_LBH</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EdgeWeight
</span><span class="hs-number">0.875</span></span><span>
</span><span id="line-1146"></span><span>        </span><span class="hs-comment">-- successors</span><span>
</span><span id="line-1147"></span><span>        </span><span id="local-6989586621681020086"><span class="annot"><span class="annottext">successors :: [(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var hs-var">successors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
CFG -&gt; Label -&gt; [(Label, EdgeInfo)]
</span><a href="GHC.CmmToAsm.CFG.html#getSuccessorEdges"><span class="hs-identifier hs-var">getSuccessorEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-1148"></span><span>        </span><span class="hs-comment">-- backedges</span><span>
</span><span id="line-1149"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681020085"><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020085"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020080"><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020080"><span class="hs-identifier hs-var">not_m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Label, EdgeInfo) -&gt; Bool)
-&gt; [(Label, EdgeInfo)]
-&gt; ([(Label, EdgeInfo)], [(Label, EdgeInfo)])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020040"><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020040"><span class="hs-identifier hs-var">succ</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Edge -&gt; Set Edge -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">S.member</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020040"><span class="hs-identifier hs-var">succ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set Edge
</span><a href="#local-6989586621681020094"><span class="hs-identifier hs-var">backedges</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Label, EdgeInfo)]
</span><a href="#local-6989586621681020086"><span class="hs-identifier hs-var">successors</span></a></span><span>
</span><span id="line-1150"></span><span>
</span><span id="line-1151"></span><span>        </span><span class="hs-comment">-- Heuristics return nothing if they don't say anything about this branch</span><span>
</span><span id="line-1152"></span><span>        </span><span class="hs-comment">-- or Just (prob_s1) where prob_s1 is the likelihood for s1 to be the</span><span>
</span><span id="line-1153"></span><span>        </span><span class="hs-comment">-- taken branch. s1 is the branch in the true case.</span><span>
</span><span id="line-1154"></span><span>
</span><span id="line-1155"></span><span>        </span><span class="hs-comment">-- Loop exit heuristic.</span><span>
</span><span id="line-1156"></span><span>        </span><span class="hs-comment">-- We are unlikely to leave a loop unless it's to enter another one.</span><span>
</span><span id="line-1157"></span><span>        </span><span id="local-6989586621681020037"><span class="annot"><span class="annottext">pred_LEH :: Double
</span><a href="#local-6989586621681020037"><span class="hs-identifier hs-var hs-var">pred_LEH</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0.75</span></span><span>
</span><span id="line-1158"></span><span>        </span><span class="hs-comment">-- If and only if no successor is a loopheader,</span><span>
</span><span id="line-1159"></span><span>        </span><span class="hs-comment">-- then we will likely not exit the current loop body.</span><span>
</span><span id="line-1160"></span><span>        </span><span class="annot"><a href="#local-6989586621681020062"><span class="hs-identifier hs-type">lehPredicts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TargetNodeInfo"><span class="hs-identifier hs-type">TargetNodeInfo</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#TargetNodeInfo"><span class="hs-identifier hs-type">TargetNodeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span>
</span><span id="line-1161"></span><span>        </span><span id="local-6989586621681020062"><span class="annot"><span class="annottext">lehPredicts :: ((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
</span><a href="#local-6989586621681020062"><span class="hs-identifier hs-var hs-var">lehPredicts</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681020036"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020036"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020035"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020035"><span class="hs-identifier hs-var">_s1_info</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">(</span><span id="local-6989586621681020034"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020034"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020033"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681020033"><span class="hs-identifier hs-var">_s2_info</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1162"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Set Label -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">S.member</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020036"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">Set Label
</span><a href="#local-6989586621681020090"><span class="hs-identifier hs-var">loopHeads</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Set Label -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">S.member</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020034"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">Set Label
</span><a href="#local-6989586621681020090"><span class="hs-identifier hs-var">loopHeads</span></a></span><span>
</span><span id="line-1163"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Double
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1164"></span><span>
</span><span id="line-1165"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1166"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">--pprTrace &quot;lehPredict:&quot; (ppr $ compare s1Level s2Level) $</span><span>
</span><span id="line-1167"></span><span>            </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Maybe Int -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-identifier hs-var">compare</span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681020032"><span class="hs-identifier hs-var">s1Level</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681020031"><span class="hs-identifier hs-var">s2Level</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1168"></span><span>                </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">EQ</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Double
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1169"></span><span>                </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">LT</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Maybe Double
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1</span></span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020037"><span class="hs-identifier hs-var">pred_LEH</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--s1 exits to a shallower loop level (exits loop)</span><span>
</span><span id="line-1170"></span><span>                </span><span class="annot"><span class="annottext">Ordering
</span><span class="hs-identifier hs-var">GT</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Maybe Double
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681020037"><span class="hs-identifier hs-var">pred_LEH</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">--s1 exits to a deeper loop level</span><span>
</span><span id="line-1171"></span><span>            </span><span class="hs-keyword">where</span><span>
</span><span id="line-1172"></span><span>                </span><span id="local-6989586621681020032"><span class="annot"><span class="annottext">s1Level :: Maybe Int
</span><a href="#local-6989586621681020032"><span class="hs-identifier hs-var hs-var">s1Level</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Int -&gt; Maybe Int
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020036"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020099"><span class="hs-identifier hs-var">loopLevels</span></a></span><span>
</span><span id="line-1173"></span><span>                </span><span id="local-6989586621681020031"><span class="annot"><span class="annottext">s2Level :: Maybe Int
</span><a href="#local-6989586621681020031"><span class="hs-identifier hs-var hs-var">s2Level</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Int -&gt; Maybe Int
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681020034"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681020099"><span class="hs-identifier hs-var">loopLevels</span></a></span><span>
</span><span id="line-1174"></span><span>
</span><span id="line-1175"></span><span>        </span><span class="hs-comment">-- Comparing to a constant is unlikely to be equal.</span><span>
</span><span id="line-1176"></span><span>        </span><span id="local-6989586621681020060"><span class="annot"><span class="annottext">ohPredicts :: ((Label, EdgeInfo), (Label, EdgeInfo)) -&gt; Maybe Double
</span><a href="#local-6989586621681020060"><span class="hs-identifier hs-var hs-var">ohPredicts</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681020030"><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020030"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681020029"><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020029"><span class="hs-identifier hs-var">_s2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1177"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CmmSource"><span class="hs-identifier hs-type">CmmSource</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">trans_cmmNode :: TransitionSource -&gt; CmmNode O C
</span><a href="GHC.CmmToAsm.CFG.html#trans_cmmNode"><span class="hs-identifier hs-var">trans_cmmNode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681020028"><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020028"><span class="hs-identifier hs-var">src1</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; CFG -&gt; TransitionSource
</span><a href="GHC.CmmToAsm.CFG.html#getTransitionSource"><span class="hs-identifier hs-var">getTransitionSource</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020087"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020030"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020088"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1178"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-type">CmmCondBranch</span></a></span><span> </span><span id="local-6989586621681020019"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020019"><span class="hs-identifier hs-var">cond</span></a></span></span><span> </span><span id="local-6989586621681020018"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020018"><span class="hs-identifier hs-var">ltrue</span></a></span></span><span> </span><span id="local-6989586621681020017"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020017"><span class="hs-identifier hs-var">_lfalse</span></a></span></span><span> </span><span id="local-6989586621681020016"><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020016"><span class="hs-identifier hs-var">likely</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681020028"><span class="hs-identifier hs-var">src1</span></a></span><span>
</span><span id="line-1179"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681020016"><span class="hs-identifier hs-var">likely</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1180"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-type">CmmMachOp</span></a></span><span> </span><span id="local-6989586621681020014"><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681020014"><span class="hs-identifier hs-var">mop</span></a></span></span><span> </span><span id="local-6989586621681020013"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681020013"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020019"><span class="hs-identifier hs-var">cond</span></a></span><span>
</span><span id="line-1181"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.MachOp.html#MO_Eq"><span class="hs-identifier hs-type">MO_Eq</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681020014"><span class="hs-identifier hs-var">mop</span></a></span><span>
</span><span id="line-1182"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmExpr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681020011"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681020011"><span class="annot"><span class="annottext">x :: CmmExpr
</span><a href="#local-6989586621681020011"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681020013"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1183"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo) -&gt; Label
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(Label, EdgeInfo)
</span><a href="#local-6989586621681020030"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">Label -&gt; Label -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020018"><span class="hs-identifier hs-var">ltrue</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Maybe Double
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0.3</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Maybe Double
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0.7</span></span><span>
</span><span id="line-1184"></span><span>
</span><span id="line-1185"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1186"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Double
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1187"></span><span>
</span><span id="line-1188"></span><span>        </span><span class="hs-comment">-- TODO: These are all the other heuristics from the paper.</span><span>
</span><span id="line-1189"></span><span>        </span><span class="hs-comment">-- Not all will apply, for now we just stub them out as Nothing.</span><span>
</span><span id="line-1190"></span><span>        </span><span id="local-6989586621681020061"><span class="annot"><span class="annottext">phPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020061"><span class="hs-identifier hs-var hs-var">phPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1191"></span><span>        </span><span id="local-6989586621681020059"><span class="annot"><span class="annottext">ghPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020059"><span class="hs-identifier hs-var hs-var">ghPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1192"></span><span>        </span><span id="local-6989586621681020058"><span class="annot"><span class="annottext">lhhPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020058"><span class="hs-identifier hs-var hs-var">lhhPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1193"></span><span>        </span><span id="local-6989586621681020057"><span class="annot"><span class="annottext">chPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020057"><span class="hs-identifier hs-var hs-var">chPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1194"></span><span>        </span><span id="local-6989586621681020056"><span class="annot"><span class="annottext">shPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020056"><span class="hs-identifier hs-var hs-var">shPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1195"></span><span>        </span><span id="local-6989586621681020055"><span class="annot"><span class="annottext">rhPredicts :: b -&gt; Maybe a
</span><a href="#local-6989586621681020055"><span class="hs-identifier hs-var hs-var">rhPredicts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; b -&gt; Maybe a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1196"></span><span>
</span><span id="line-1197"></span><span class="hs-comment">-- We normalize all edge weights as probabilities between 0 and 1.</span><span>
</span><span id="line-1198"></span><span class="hs-comment">-- Ignoring rounding errors all outgoing edges sum up to 1.</span><span>
</span><span id="line-1199"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#cfgEdgeProbabilities"><span class="hs-identifier hs-type">cfgEdgeProbabilities</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1200"></span><span id="cfgEdgeProbabilities"><span class="annot"><span class="annottext">cfgEdgeProbabilities :: CFG -&gt; (Label -&gt; Int) -&gt; IntMap (IntMap Double)
</span><a href="GHC.CmmToAsm.CFG.html#cfgEdgeProbabilities"><span class="hs-identifier hs-var hs-var">cfgEdgeProbabilities</span></a></span></span><span> </span><span id="local-6989586621681020008"><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020008"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681020007"><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020007"><span class="hs-identifier hs-var">toVertex</span></a></span></span><span>
</span><span id="line-1201"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap (IntMap Double)
 -&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; IntMap (IntMap Double))
-&gt; IntMap (IntMap Double) -&gt; CFG -&gt; IntMap (IntMap Double)
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
-&gt; KeyOf LabelMap -&gt; LabelMap EdgeInfo -&gt; IntMap (IntMap Double)
IntMap (IntMap Double)
-&gt; Label -&gt; LabelMap EdgeInfo -&gt; IntMap (IntMap Double)
</span><a href="#local-6989586621681020006"><span class="hs-identifier hs-var">foldEdges</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IM.empty</span></a></span><span> </span><span class="annot"><span class="annottext">CFG
</span><a href="#local-6989586621681020008"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-1202"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1203"></span><span>    </span><span id="local-6989586621681020006"><span class="annot"><span class="annottext">foldEdges :: IntMap (IntMap Double)
-&gt; Label -&gt; LabelMap EdgeInfo -&gt; IntMap (IntMap Double)
</span><a href="#local-6989586621681020006"><span class="hs-identifier hs-var hs-var">foldEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681020004"><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681020004"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681020003"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020003"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681020002"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020002"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IntMap Double
-&gt; IntMap (IntMap Double)
-&gt; IntMap (IntMap Double)
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insert"><span class="hs-identifier hs-var">IM.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020007"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681020003"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; IntMap Double
</span><a href="#local-6989586621681020000"><span class="hs-identifier hs-var">normalize</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681020002"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681020004"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1204"></span><span>
</span><span id="line-1205"></span><span>    </span><span class="annot"><a href="#local-6989586621681020000"><span class="hs-identifier hs-type">normalize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#EdgeInfo"><span class="hs-identifier hs-type">EdgeInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1206"></span><span>    </span><span id="local-6989586621681020000"><span class="annot"><span class="annottext">normalize :: LabelMap EdgeInfo -&gt; IntMap Double
</span><a href="#local-6989586621681020000"><span class="hs-identifier hs-var hs-var">normalize</span></a></span></span><span> </span><span id="local-6989586621681019999"><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681019999"><span class="hs-identifier hs-var">weightMap</span></a></span></span><span>
</span><span id="line-1207"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019998"><span class="hs-identifier hs-var">edgeCount</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap Double -&gt; KeyOf LabelMap -&gt; EdgeInfo -&gt; IntMap Double)
-&gt; IntMap Double -&gt; LabelMap EdgeInfo -&gt; IntMap Double
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019997"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019997"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681019996"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681019996"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; IntMap Double -&gt; IntMap Double
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insert"><span class="hs-identifier hs-var">IM.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020007"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681019996"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019997"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap Double
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IM.empty</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681019999"><span class="hs-identifier hs-var">weightMap</span></a></span><span>
</span><span id="line-1208"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap Double -&gt; KeyOf LabelMap -&gt; EdgeInfo -&gt; IntMap Double)
-&gt; IntMap Double -&gt; LabelMap EdgeInfo -&gt; IntMap Double
forall (map :: * -&gt; *) b a.
IsMap map =&gt;
(b -&gt; KeyOf map -&gt; a -&gt; b) -&gt; b -&gt; map a -&gt; b
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFoldlWithKey"><span class="hs-identifier hs-var">mapFoldlWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019995"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019995"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681019994"><span class="annot"><span class="annottext">KeyOf LabelMap
</span><a href="#local-6989586621681019994"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; IntMap Double -&gt; IntMap Double
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insert"><span class="hs-identifier hs-var">IM.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Int
</span><a href="#local-6989586621681020007"><span class="hs-identifier hs-var">toVertex</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681019994"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Label -&gt; Double
</span><a href="#local-6989586621681019993"><span class="hs-identifier hs-var">normalWeight</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681019994"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019995"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap Double
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IM.empty</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681019999"><span class="hs-identifier hs-var">weightMap</span></a></span><span>
</span><span id="line-1209"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1210"></span><span>        </span><span id="local-6989586621681019998"><span class="annot"><span class="annottext">edgeCount :: Int
</span><a href="#local-6989586621681019998"><span class="hs-identifier hs-var hs-var">edgeCount</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo -&gt; Int
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; Int
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapSize"><span class="hs-identifier hs-var">mapSize</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681019999"><span class="hs-identifier hs-var">weightMap</span></a></span><span>
</span><span id="line-1211"></span><span>        </span><span class="hs-comment">-- Negative weights are generally allowed but are mapped to zero.</span><span>
</span><span id="line-1212"></span><span>        </span><span class="hs-comment">-- We then check if there is at least one non-zero edge and if not</span><span>
</span><span id="line-1213"></span><span>        </span><span class="hs-comment">-- assign uniform weights to all branches.</span><span>
</span><span id="line-1214"></span><span>        </span><span id="local-6989586621681019992"><span class="annot"><span class="annottext">minWeight :: Double
</span><a href="#local-6989586621681019992"><span class="hs-identifier hs-var hs-var">minWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span>
</span><span id="line-1215"></span><span>        </span><span id="local-6989586621681019991"><span class="annot"><span class="annottext">weightMap' :: LabelMap Double
</span><a href="#local-6989586621681019991"><span class="hs-identifier hs-var hs-var">weightMap'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; Double) -&gt; LabelMap EdgeInfo -&gt; LabelMap Double
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019990"><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681019990"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeWeight -&gt; Double
</span><a href="GHC.CmmToAsm.CFG.html#weightToDouble"><span class="hs-identifier hs-var hs-var">weightToDouble</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeWeight -&gt; Double)
-&gt; (EdgeInfo -&gt; EdgeWeight) -&gt; EdgeInfo -&gt; Double
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo -&gt; EdgeWeight
</span><a href="GHC.CmmToAsm.CFG.html#edgeWeight"><span class="hs-identifier hs-var hs-var">edgeWeight</span></a></span><span> </span><span class="annot"><span class="annottext">(EdgeInfo -&gt; Double) -&gt; EdgeInfo -&gt; Double
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">EdgeInfo
</span><a href="#local-6989586621681019990"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019992"><span class="hs-identifier hs-var">minWeight</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap EdgeInfo
</span><a href="#local-6989586621681019999"><span class="hs-identifier hs-var">weightMap</span></a></span><span>
</span><span id="line-1216"></span><span>        </span><span id="local-6989586621681019989"><span class="annot"><span class="annottext">totalWeight :: Double
</span><a href="#local-6989586621681019989"><span class="hs-identifier hs-var hs-var">totalWeight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap Double -&gt; Double
forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#sum"><span class="hs-identifier hs-var">sum</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Double
</span><a href="#local-6989586621681019991"><span class="hs-identifier hs-var">weightMap'</span></a></span><span>
</span><span id="line-1217"></span><span>
</span><span id="line-1218"></span><span>        </span><span class="annot"><a href="#local-6989586621681019993"><span class="hs-identifier hs-type">normalWeight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span>
</span><span id="line-1219"></span><span>        </span><span id="local-6989586621681019993"><span class="annot"><span class="annottext">normalWeight :: Label -&gt; Double
</span><a href="#local-6989586621681019993"><span class="hs-identifier hs-var hs-var">normalWeight</span></a></span></span><span> </span><span id="local-6989586621681019987"><span class="annot"><span class="annottext">Label
</span><a href="#local-6989586621681019987"><span class="hs-identifier hs-var">bid</span></a></span></span><span>
</span><span id="line-1220"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019989"><span class="hs-identifier hs-var">totalWeight</span></a></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1221"></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Double
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019998"><span class="hs-identifier hs-var">edgeCount</span></a></span><span>
</span><span id="line-1222"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681019986"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019986"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Double -&gt; Maybe Double
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
Label
</span><a href="#local-6989586621681019987"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Double
</span><a href="#local-6989586621681019991"><span class="hs-identifier hs-var">weightMap'</span></a></span><span>
</span><span id="line-1223"></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019986"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019989"><span class="hs-identifier hs-var">totalWeight</span></a></span><span>
</span><span id="line-1224"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Double
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;impossible&quot;</span></span><span>
</span><span id="line-1225"></span><span>
</span><span id="line-1226"></span><span class="hs-comment">-- This is the fixpoint algorithm from</span><span>
</span><span id="line-1227"></span><span class="hs-comment">--   &quot;Static Branch Prediction and Program Profile Analysis&quot; by Y Wu, JR Larus</span><span>
</span><span id="line-1228"></span><span class="hs-comment">-- The adaption to Haskell is my own.</span><span>
</span><span id="line-1229"></span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#calcFreqs"><span class="hs-identifier hs-type">calcFreqs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">]</span><span>
</span><span id="line-1230"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Arr.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#Prob"><span class="hs-identifier hs-type">Prob</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1231"></span><span id="calcFreqs"><span class="annot"><span class="annottext">calcFreqs :: IntMap (IntMap Double)
-&gt; [(Int, Int)]
-&gt; [(Int, [Int])]
-&gt; [Int]
-&gt; (Array Int Double, IntMap (IntMap Double))
</span><a href="GHC.CmmToAsm.CFG.html#calcFreqs"><span class="hs-identifier hs-var hs-var">calcFreqs</span></a></span></span><span> </span><span id="local-6989586621681019985"><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span id="local-6989586621681019984"><span class="annot"><span class="annottext">[(Int, Int)]
</span><a href="#local-6989586621681019984"><span class="hs-identifier hs-var">backEdges</span></a></span></span><span> </span><span id="local-6989586621681019983"><span class="annot"><span class="annottext">[(Int, [Int])]
</span><a href="#local-6989586621681019983"><span class="hs-identifier hs-var">loops</span></a></span></span><span> </span><span id="local-6989586621681019982"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019982"><span class="hs-identifier hs-var">revPostOrder</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s (Array Int Double, IntMap (IntMap Double)))
-&gt; (Array Int Double, IntMap (IntMap Double))
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. ST s (Array Int Double, IntMap (IntMap Double)))
 -&gt; (Array Int Double, IntMap (IntMap Double)))
-&gt; (forall s. ST s (Array Int Double, IntMap (IntMap Double)))
-&gt; (Array Int Double, IntMap (IntMap Double))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1232"></span><span>    </span><span id="local-6989586621681019884"><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span id="local-6989586621681019883"><span class="annot"><span class="annottext">(Int, Int) -&gt; Bool -&gt; ST s (STUArray s Int Bool)
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
(i, i) -&gt; e -&gt; m (a i e)
</span><a href="../../array/src/Data.Array.Base.html#newArray"><span class="hs-identifier hs-var">newArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019876"><span class="hs-identifier hs-var">nodeCount</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681019883"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#STUArray"><span class="hs-identifier hs-type">STUArray</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681019883"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span></span><span>
</span><span id="line-1233"></span><span>    </span><span id="local-6989586621681019875"><span class="annot"><span class="annottext">STUArray s Int Double
</span><a href="#local-6989586621681019875"><span class="hs-identifier hs-var">blockFreqs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span id="local-6989586621681019874"><span class="annot"><span class="annottext">(Int, Int) -&gt; Double -&gt; ST s (STUArray s Int Double)
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
(i, i) -&gt; e -&gt; m (a i e)
</span><a href="../../array/src/Data.Array.Base.html#newArray"><span class="hs-identifier hs-var">newArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019876"><span class="hs-identifier hs-var">nodeCount</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0.0</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681019874"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#STUArray"><span class="hs-identifier hs-type">STUArray</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681019874"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">)</span></span><span>
</span><span id="line-1234"></span><span>    </span><span id="local-6989586621681019867"><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019867"><span class="hs-identifier hs-var">edgeProbs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double) -&gt; ST s (STRef s (IntMap (IntMap Double)))
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1235"></span><span>    </span><span id="local-6989586621681019865"><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019865"><span class="hs-identifier hs-var">edgeBackProbs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double) -&gt; ST s (STRef s (IntMap (IntMap Double)))
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1236"></span><span>
</span><span id="line-1237"></span><span>    </span><span class="hs-comment">-- let traceArray a = do</span><span>
</span><span id="line-1238"></span><span>    </span><span class="hs-comment">--       vs &lt;- forM [0..nodeCount-1] $ \i -&gt; readArray a i &gt;&gt;= (\v -&gt; return (i,v))</span><span>
</span><span id="line-1239"></span><span>          </span><span class="hs-comment">-- trace (&quot;array: &quot; ++ show vs) $ return ()</span><span>
</span><span id="line-1240"></span><span>
</span><span id="line-1241"></span><span>    </span><span class="hs-keyword">let</span><span>  </span><span class="hs-comment">-- See #1600, we need to inline or unboxing makes perf worse.</span><span>
</span><span id="line-1242"></span><span>        </span><span class="hs-comment">-- {-# INLINE getFreq #-}</span><span>
</span><span id="line-1243"></span><span>        </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="#local-6989586621681019864"><span class="hs-pragma hs-type">visited</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-1244"></span><span>        </span><span id="local-6989586621681019864"><span class="annot"><span class="annottext">visited :: Int -&gt; ST s Bool
</span><a href="#local-6989586621681019864"><span class="hs-identifier hs-var hs-var">visited</span></a></span></span><span> </span><span id="local-6989586621681019863"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019863"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool -&gt; Int -&gt; ST s Bool
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; m e
</span><a href="../../array/src/Data.Array.Base.html#unsafeRead"><span class="hs-identifier hs-var">unsafeRead</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019863"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-1245"></span><span>        </span><span id="local-6989586621681019862"><span class="annot"><span class="annottext">getFreq :: Int -&gt; ST s Double
</span><a href="#local-6989586621681019862"><span class="hs-identifier hs-var hs-var">getFreq</span></a></span></span><span> </span><span id="local-6989586621681019861"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019861"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Double -&gt; Int -&gt; ST s Double
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; m e
</span><a href="../../array/src/Data.Array.Base.html#unsafeRead"><span class="hs-identifier hs-var">unsafeRead</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Double
</span><a href="#local-6989586621681019875"><span class="hs-identifier hs-var">blockFreqs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019861"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-1246"></span><span>        </span><span class="hs-comment">-- setFreq :: forall s. Int -&gt; Double -&gt; ST s ()</span><span>
</span><span id="line-1247"></span><span>        </span><span id="local-6989586621681019860"><span class="annot"><span class="annottext">setFreq :: Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019860"><span class="hs-identifier hs-var hs-var">setFreq</span></a></span></span><span> </span><span id="local-6989586621681019859"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019859"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681019858"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019858"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Double -&gt; Int -&gt; Double -&gt; ST s ()
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; e -&gt; m ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Double
</span><a href="#local-6989586621681019875"><span class="hs-identifier hs-var">blockFreqs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019859"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019858"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-1248"></span><span>        </span><span class="hs-comment">-- setVisited :: forall s. Node -&gt; ST s ()</span><span>
</span><span id="line-1249"></span><span>        </span><span id="local-6989586621681019857"><span class="annot"><span class="annottext">setVisited :: Int -&gt; ST s ()
</span><a href="#local-6989586621681019857"><span class="hs-identifier hs-var hs-var">setVisited</span></a></span></span><span> </span><span id="local-6989586621681019856"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019856"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool -&gt; Int -&gt; Bool -&gt; ST s ()
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; e -&gt; m ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019856"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1250"></span><span>        </span><span class="hs-comment">-- Frequency/probability that edge is taken.</span><span>
</span><span id="line-1251"></span><span>        </span><span id="local-6989586621681019849"><span class="annot"><span class="annottext">getProb' :: STRef s (IntMap (IntMap b)) -&gt; Int -&gt; Int -&gt; ST s b
</span><a href="#local-6989586621681019849"><span class="hs-identifier hs-var hs-var">getProb'</span></a></span></span><span> </span><span id="local-6989586621681019848"><span class="annot"><span class="annottext">STRef s (IntMap (IntMap b))
</span><a href="#local-6989586621681019848"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span id="local-6989586621681019847"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019847"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019846"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019846"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap b)) -&gt; ST s (IntMap (IntMap b))
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap b))
</span><a href="#local-6989586621681019848"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">ST s (IntMap (IntMap b)) -&gt; (IntMap (IntMap b) -&gt; ST s b) -&gt; ST s b
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span>
</span><span id="line-1252"></span><span>            </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019844"><span class="annot"><span class="annottext">IntMap (IntMap b)
</span><a href="#local-6989586621681019844"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1253"></span><span>                </span><span class="annot"><span class="annottext">b -&gt; ST s b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; ST s b)
-&gt; (Maybe (IntMap b) -&gt; b) -&gt; Maybe (IntMap b) -&gt; ST s b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1254"></span><span>                        </span><span class="annot"><span class="annottext">b -&gt; Maybe b -&gt; b
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; b
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getFreq 1&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe b -&gt; b)
-&gt; (Maybe (IntMap b) -&gt; Maybe b) -&gt; Maybe (IntMap b) -&gt; b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1255"></span><span>                        </span><span class="annot"><span class="annottext">Int -&gt; IntMap b -&gt; Maybe b
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019846"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">(IntMap b -&gt; Maybe b)
-&gt; (Maybe (IntMap b) -&gt; IntMap b) -&gt; Maybe (IntMap b) -&gt; Maybe b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1256"></span><span>                        </span><span class="annot"><span class="annottext">IntMap b -&gt; Maybe (IntMap b) -&gt; IntMap b
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IntMap b
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getFreq 2&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe (IntMap b) -&gt; ST s b) -&gt; Maybe (IntMap b) -&gt; ST s b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1257"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; IntMap (IntMap b) -&gt; Maybe (IntMap b)
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019847"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap b)
</span><a href="#local-6989586621681019844"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1258"></span><span>            </span><span class="hs-special">)</span><span>
</span><span id="line-1259"></span><span>        </span><span id="local-6989586621681019837"><span class="annot"><span class="annottext">setProb' :: STRef s (IntMap (IntMap a)) -&gt; Int -&gt; Int -&gt; a -&gt; ST s ()
</span><a href="#local-6989586621681019837"><span class="hs-identifier hs-var hs-var">setProb'</span></a></span></span><span> </span><span id="local-6989586621681019836"><span class="annot"><span class="annottext">STRef s (IntMap (IntMap a))
</span><a href="#local-6989586621681019836"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span id="local-6989586621681019835"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019835"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019834"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019834"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span id="local-6989586621681019833"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681019833"><span class="hs-identifier hs-var">prob</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1260"></span><span>          </span><span id="local-6989586621681019832"><span class="annot"><span class="annottext">IntMap (IntMap a)
</span><a href="#local-6989586621681019832"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap a)) -&gt; ST s (IntMap (IntMap a))
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap a))
</span><a href="#local-6989586621681019836"><span class="hs-identifier hs-var">arr</span></a></span><span>
</span><span id="line-1261"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681019831"><span class="annot"><span class="annottext">m :: IntMap a
</span><a href="#local-6989586621681019831"><span class="hs-identifier hs-var hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IntMap a -&gt; Maybe (IntMap a) -&gt; IntMap a
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IntMap a
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Foo&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe (IntMap a) -&gt; IntMap a) -&gt; Maybe (IntMap a) -&gt; IntMap a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap (IntMap a) -&gt; Maybe (IntMap a)
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019835"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap a)
</span><a href="#local-6989586621681019832"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-1262"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681019830"><span class="annot"><span class="annottext">m' :: IntMap a
</span><a href="#local-6989586621681019830"><span class="hs-identifier hs-var hs-var">m'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; a -&gt; IntMap a -&gt; IntMap a
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insert"><span class="hs-identifier hs-var">IM.insert</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019834"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681019833"><span class="hs-identifier hs-var">prob</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap a
</span><a href="#local-6989586621681019831"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-1263"></span><span>          </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap a)) -&gt; IntMap (IntMap a) -&gt; ST s ()
forall s a. STRef s a -&gt; a -&gt; ST s ()
</span><a href="../../base/src/GHC.STRef.html#writeSTRef"><span class="hs-identifier hs-var">writeSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap a))
</span><a href="#local-6989586621681019836"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">(IntMap (IntMap a) -&gt; ST s ()) -&gt; IntMap (IntMap a) -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; IntMap a -&gt; IntMap (IntMap a) -&gt; IntMap (IntMap a)
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insert"><span class="hs-identifier hs-var">IM.insert</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019835"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap a
</span><a href="#local-6989586621681019830"><span class="hs-identifier hs-var">m'</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap a)
</span><a href="#local-6989586621681019832"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1264"></span><span>
</span><span id="line-1265"></span><span>        </span><span id="local-6989586621681019828"><span class="annot"><span class="annottext">getEdgeFreq :: Int -&gt; Int -&gt; ST s Double
</span><a href="#local-6989586621681019828"><span class="hs-identifier hs-var hs-var">getEdgeFreq</span></a></span></span><span> </span><span id="local-6989586621681019827"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019827"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019826"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019826"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double)) -&gt; Int -&gt; Int -&gt; ST s Double
forall {s} {b}. STRef s (IntMap (IntMap b)) -&gt; Int -&gt; Int -&gt; ST s b
</span><a href="#local-6989586621681019849"><span class="hs-identifier hs-var">getProb'</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019867"><span class="hs-identifier hs-var">edgeProbs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019827"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019826"><span class="hs-identifier hs-var">b2</span></a></span><span>
</span><span id="line-1266"></span><span>        </span><span id="local-6989586621681019825"><span class="annot"><span class="annottext">setEdgeFreq :: Int -&gt; Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019825"><span class="hs-identifier hs-var hs-var">setEdgeFreq</span></a></span></span><span> </span><span id="local-6989586621681019824"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019824"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019823"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019823"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double)) -&gt; Int -&gt; Int -&gt; Double -&gt; ST s ()
forall {s} {a}.
STRef s (IntMap (IntMap a)) -&gt; Int -&gt; Int -&gt; a -&gt; ST s ()
</span><a href="#local-6989586621681019837"><span class="hs-identifier hs-var">setProb'</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019867"><span class="hs-identifier hs-var">edgeProbs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019824"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019823"><span class="hs-identifier hs-var">b2</span></a></span><span>
</span><span id="line-1267"></span><span>        </span><span id="local-6989586621681019822"><span class="annot"><span class="annottext">getProb :: Int -&gt; Int -&gt; Double
</span><a href="#local-6989586621681019822"><span class="hs-identifier hs-var hs-var">getProb</span></a></span></span><span> </span><span id="local-6989586621681019821"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019821"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019820"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019820"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Maybe Double -&gt; Double
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Double
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getProb&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe Double -&gt; Double) -&gt; Maybe Double -&gt; Double
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1268"></span><span>            </span><span id="local-6989586621681019819"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019819"><span class="hs-identifier hs-var">m'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap (IntMap Double) -&gt; Maybe (IntMap Double)
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019821"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1269"></span><span>            </span><span class="annot"><span class="annottext">Int -&gt; IntMap Double -&gt; Maybe Double
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019820"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019819"><span class="hs-identifier hs-var">m'</span></a></span><span>
</span><span id="line-1270"></span><span>
</span><span id="line-1271"></span><span>        </span><span id="local-6989586621681019818"><span class="annot"><span class="annottext">getBackProb :: Int -&gt; Int -&gt; ST s Double
</span><a href="#local-6989586621681019818"><span class="hs-identifier hs-var hs-var">getBackProb</span></a></span></span><span> </span><span id="local-6989586621681019817"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019817"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019816"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019816"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double)) -&gt; Int -&gt; Int -&gt; ST s Double
forall {s} {b}. STRef s (IntMap (IntMap b)) -&gt; Int -&gt; Int -&gt; ST s b
</span><a href="#local-6989586621681019849"><span class="hs-identifier hs-var">getProb'</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019865"><span class="hs-identifier hs-var">edgeBackProbs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019817"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019816"><span class="hs-identifier hs-var">b2</span></a></span><span>
</span><span id="line-1272"></span><span>        </span><span id="local-6989586621681019815"><span class="annot"><span class="annottext">setBackProb :: Int -&gt; Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019815"><span class="hs-identifier hs-var hs-var">setBackProb</span></a></span></span><span> </span><span id="local-6989586621681019814"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019814"><span class="hs-identifier hs-var">b1</span></a></span></span><span> </span><span id="local-6989586621681019813"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019813"><span class="hs-identifier hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double)) -&gt; Int -&gt; Int -&gt; Double -&gt; ST s ()
forall {s} {a}.
STRef s (IntMap (IntMap a)) -&gt; Int -&gt; Int -&gt; a -&gt; ST s ()
</span><a href="#local-6989586621681019837"><span class="hs-identifier hs-var">setProb'</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019865"><span class="hs-identifier hs-var">edgeBackProbs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019814"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019813"><span class="hs-identifier hs-var">b2</span></a></span><span>
</span><span id="line-1273"></span><span>
</span><span id="line-1274"></span><span>
</span><span id="line-1275"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- calcOutFreqs :: Node -&gt; ST s ()</span><span>
</span><span id="line-1276"></span><span>        </span><span id="local-6989586621681019812"><span class="annot"><span class="annottext">calcOutFreqs :: Int -&gt; Int -&gt; ST s [()]
</span><a href="#local-6989586621681019812"><span class="hs-identifier hs-var hs-var">calcOutFreqs</span></a></span></span><span> </span><span id="local-6989586621681019811"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019811"><span class="hs-identifier hs-var">bhead</span></a></span></span><span> </span><span id="local-6989586621681019810"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1277"></span><span>          </span><span class="hs-glyph">!</span><span id="local-6989586621681019809"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019809"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s Double
</span><a href="#local-6989586621681019862"><span class="hs-identifier hs-var">getFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1278"></span><span>          </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s ()) -&gt; ST s [()]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#forM"><span class="hs-identifier hs-var">forM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; [Int]
</span><a href="#local-6989586621681019807"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Int -&gt; ST s ()) -&gt; ST s [()]) -&gt; (Int -&gt; ST s ()) -&gt; ST s [()]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681019806"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019806"><span class="hs-identifier hs-var">bi</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1279"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681019805"><span class="annot"><span class="annottext">prob :: Double
</span><a href="#local-6989586621681019805"><span class="hs-identifier hs-var hs-var">prob</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Double
</span><a href="#local-6989586621681019822"><span class="hs-identifier hs-var">getProb</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019806"><span class="hs-identifier hs-var">bi</span></a></span><span>
</span><span id="line-1280"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681019804"><span class="annot"><span class="annottext">succFreq :: Double
</span><a href="#local-6989586621681019804"><span class="hs-identifier hs-var hs-var">succFreq</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019809"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019805"><span class="hs-identifier hs-var">prob</span></a></span><span>
</span><span id="line-1281"></span><span>            </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019825"><span class="hs-identifier hs-var">setEdgeFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019806"><span class="hs-identifier hs-var">bi</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019804"><span class="hs-identifier hs-var">succFreq</span></a></span><span>
</span><span id="line-1282"></span><span>            </span><span class="hs-comment">-- traceM $ &quot;SetOut: &quot; ++ show (block, bi, f, prob, succFreq)</span><span>
</span><span id="line-1283"></span><span>            </span><span class="annot"><span class="annottext">Bool -&gt; ST s () -&gt; ST s ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019806"><span class="hs-identifier hs-var">bi</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019811"><span class="hs-identifier hs-var">bhead</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(ST s () -&gt; ST s ()) -&gt; ST s () -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019815"><span class="hs-identifier hs-var">setBackProb</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019810"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019806"><span class="hs-identifier hs-var">bi</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019804"><span class="hs-identifier hs-var">succFreq</span></a></span><span>
</span><span id="line-1284"></span><span>
</span><span id="line-1285"></span><span>
</span><span id="line-1286"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681019802"><span class="annot"><span class="annottext">propFreq :: Int -&gt; Int -&gt; ST s [()]
</span><a href="#local-6989586621681019802"><span class="hs-identifier hs-var hs-var">propFreq</span></a></span></span><span> </span><span id="local-6989586621681019801"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span id="local-6989586621681019800"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019800"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1287"></span><span>            </span><span class="hs-comment">-- traceM (&quot;prop:&quot; ++ show (block,head))</span><span>
</span><span id="line-1288"></span><span>            </span><span class="hs-comment">-- traceShowM block</span><span>
</span><span id="line-1289"></span><span>
</span><span id="line-1290"></span><span>            </span><span class="hs-glyph">!</span><span id="local-6989586621681019799"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019799"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s Bool
</span><a href="#local-6989586621681019864"><span class="hs-identifier hs-var">visited</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1291"></span><span>            </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019799"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1292"></span><span>                </span><span class="annot"><span class="annottext">() -&gt; ST s ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">--Dont look at nodes twice</span><span>
</span><span id="line-1293"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019800"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1294"></span><span>                </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019860"><span class="hs-identifier hs-var">setFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="hs-comment">-- Loop header frequency is always 1</span><span>
</span><span id="line-1295"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1296"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681019798"><span class="annot"><span class="annottext">preds :: [Int]
</span><a href="#local-6989586621681019798"><span class="hs-identifier hs-var hs-var">preds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IntSet -&gt; [Int]
</span><a href="../../containers/src/Data.IntSet.Internal.html#elems"><span class="hs-identifier hs-var">IS.elems</span></a></span><span> </span><span class="annot"><span class="annottext">(IntSet -&gt; [Int]) -&gt; IntSet -&gt; [Int]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntSet
</span><a href="#local-6989586621681019796"><span class="hs-identifier hs-var">predecessors</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1297"></span><span>                </span><span id="local-6989586621681019795"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019795"><span class="hs-identifier hs-var">irreducible</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([Bool] -&gt; Bool) -&gt; ST s [Bool] -&gt; ST s Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(ST s [Bool] -&gt; ST s Bool) -&gt; ST s [Bool] -&gt; ST s Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s Bool) -&gt; ST s [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#forM"><span class="hs-identifier hs-var">forM</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019798"><span class="hs-identifier hs-var">preds</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; ST s Bool) -&gt; ST s [Bool])
-&gt; (Int -&gt; ST s Bool) -&gt; ST s [Bool]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681019793"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019793"><span class="hs-identifier hs-var">bp</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1298"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681019792"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019792"><span class="hs-identifier hs-var">bp_visited</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s Bool
</span><a href="#local-6989586621681019864"><span class="hs-identifier hs-var">visited</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019793"><span class="hs-identifier hs-var">bp</span></a></span><span>
</span><span id="line-1299"></span><span>                    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681019791"><span class="annot"><span class="annottext">bp_backedge :: Bool
</span><a href="#local-6989586621681019791"><span class="hs-identifier hs-var hs-var">bp_backedge</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
</span><a href="#local-6989586621681019790"><span class="hs-identifier hs-var">isBackEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019793"><span class="hs-identifier hs-var">bp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1300"></span><span>                    </span><span class="annot"><span class="annottext">Bool -&gt; ST s Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019792"><span class="hs-identifier hs-var">bp_visited</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019791"><span class="hs-identifier hs-var">bp_backedge</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1301"></span><span>
</span><span id="line-1302"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681019795"><span class="hs-identifier hs-var">irreducible</span></a></span><span>
</span><span id="line-1303"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; ST s ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Rare we don't care</span><span>
</span><span id="line-1304"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1305"></span><span>                    </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019860"><span class="hs-identifier hs-var">setFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1306"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681019789"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019789"><span class="hs-identifier hs-var">cycleProb</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Double] -&gt; Double
forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#sum"><span class="hs-identifier hs-var">sum</span></a></span><span> </span><span class="annot"><span class="annottext">([Double] -&gt; Double) -&gt; ST s [Double] -&gt; ST s Double
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s Double) -&gt; ST s [Double]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#forM"><span class="hs-identifier hs-var">forM</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019798"><span class="hs-identifier hs-var">preds</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; ST s Double) -&gt; ST s [Double])
-&gt; (Int -&gt; ST s Double) -&gt; ST s [Double]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681019788"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019788"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1307"></span><span>                        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
</span><a href="#local-6989586621681019790"><span class="hs-identifier hs-var">isBackEdge</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019788"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1308"></span><span>                            </span><span class="hs-keyword">then</span><span>
</span><span id="line-1309"></span><span>                                </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; ST s Double
</span><a href="#local-6989586621681019818"><span class="hs-identifier hs-var">getBackProb</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019788"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1310"></span><span>                            </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1311"></span><span>                                </span><span class="hs-glyph">!</span><span id="local-6989586621681019787"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019787"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s Double
</span><a href="#local-6989586621681019862"><span class="hs-identifier hs-var">getFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1312"></span><span>                                </span><span class="hs-glyph">!</span><span id="local-6989586621681019786"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019786"><span class="hs-identifier hs-var">prob</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; ST s Double
</span><a href="#local-6989586621681019828"><span class="hs-identifier hs-var">getEdgeFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019788"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1313"></span><span>                                </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019860"><span class="hs-identifier hs-var">setFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">(Double -&gt; ST s ()) -&gt; Double -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019787"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019786"><span class="hs-identifier hs-var">prob</span></a></span><span>
</span><span id="line-1314"></span><span>                                </span><span class="annot"><span class="annottext">Double -&gt; ST s Double
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-1315"></span><span>                    </span><span class="hs-comment">-- traceM $ &quot;cycleProb:&quot; ++ show cycleProb</span><span>
</span><span id="line-1316"></span><span>                    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681019780"><span class="annot"><span class="annottext">limit :: Double
</span><a href="#local-6989586621681019780"><span class="hs-identifier hs-var hs-var">limit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1</span></span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">512</span></span><span> </span><span class="hs-comment">-- Paper uses 1 - epsilon, but this works.</span><span>
</span><span id="line-1317"></span><span>                                          </span><span class="hs-comment">-- determines how large likelyhoods in loops can grow.</span><span>
</span><span id="line-1318"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681019779"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019779"><span class="hs-identifier hs-var">cycleProb</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Double -&gt; ST s Double
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Double -&gt; ST s Double) -&gt; Double -&gt; ST s Double
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">min</span></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019789"><span class="hs-identifier hs-var">cycleProb</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019780"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="hs-comment">-- &lt;- return $ if cycleProb &gt; limit then limit else cycleProb</span><span>
</span><span id="line-1319"></span><span>                    </span><span class="hs-comment">-- traceM $ &quot;cycleProb:&quot; ++ show cycleProb</span><span>
</span><span id="line-1320"></span><span>
</span><span id="line-1321"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681019777"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019777"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s Double
</span><a href="#local-6989586621681019862"><span class="hs-identifier hs-var">getFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1322"></span><span>                    </span><span class="annot"><span class="annottext">Int -&gt; Double -&gt; ST s ()
</span><a href="#local-6989586621681019860"><span class="hs-identifier hs-var">setFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019777"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681019779"><span class="hs-identifier hs-var">cycleProb</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1323"></span><span>
</span><span id="line-1324"></span><span>            </span><span class="annot"><span class="annottext">Int -&gt; ST s ()
</span><a href="#local-6989586621681019857"><span class="hs-identifier hs-var">setVisited</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1325"></span><span>            </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; ST s [()]
</span><a href="#local-6989586621681019812"><span class="hs-identifier hs-var">calcOutFreqs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019800"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019801"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-1326"></span><span>
</span><span id="line-1327"></span><span>    </span><span class="hs-comment">-- Loops, by nesting, inner to outer</span><span>
</span><span id="line-1328"></span><span>    </span><span class="annot"><span class="annottext">[(Int, [Int])] -&gt; ((Int, [Int]) -&gt; ST s ()) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="annot"><span class="annottext">[(Int, [Int])]
</span><a href="#local-6989586621681019983"><span class="hs-identifier hs-var">loops</span></a></span><span> </span><span class="annot"><span class="annottext">(((Int, [Int]) -&gt; ST s ()) -&gt; ST s ())
-&gt; ((Int, [Int]) -&gt; ST s ()) -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681019775"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019775"><span class="hs-identifier hs-var">head</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681019774"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019774"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1329"></span><span>        </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s ()) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">..</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019876"><span class="hs-identifier hs-var">nodeCount</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019773"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019773"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool -&gt; Int -&gt; Bool -&gt; ST s ()
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; e -&gt; m ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019773"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Mark all nodes as visited.</span><span>
</span><span id="line-1330"></span><span>        </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s ()) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019774"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019772"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019772"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool -&gt; Int -&gt; Bool -&gt; ST s ()
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; e -&gt; m ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019772"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Mark all blocks reachable from head as not visited</span><span>
</span><span id="line-1331"></span><span>        </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s [()]) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019774"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; ST s [()]) -&gt; ST s ()) -&gt; (Int -&gt; ST s [()]) -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681019771"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019771"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; ST s [()]
</span><a href="#local-6989586621681019802"><span class="hs-identifier hs-var">propFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019771"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019775"><span class="hs-identifier hs-var">head</span></a></span><span>
</span><span id="line-1332"></span><span>
</span><span id="line-1333"></span><span>    </span><span class="hs-comment">-- After dealing with all loops, deal with non-looping parts of the CFG</span><span>
</span><span id="line-1334"></span><span>    </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s ()) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">..</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019876"><span class="hs-identifier hs-var">nodeCount</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019770"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019770"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool -&gt; Int -&gt; Bool -&gt; ST s ()
forall (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) i.
(MArray a e m, Ix i) =&gt;
a i e -&gt; Int -&gt; e -&gt; m ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">STUArray s Int Bool
</span><a href="#local-6989586621681019884"><span class="hs-identifier hs-var">visitedNodes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019770"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Everything in revPostOrder is reachable</span><span>
</span><span id="line-1335"></span><span>    </span><span class="annot"><span class="annottext">[Int] -&gt; (Int -&gt; ST s [()]) -&gt; ST s ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
t a -&gt; (a -&gt; m b) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#forM_"><span class="hs-identifier hs-var">forM_</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019982"><span class="hs-identifier hs-var">revPostOrder</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; ST s [()]) -&gt; ST s ()) -&gt; (Int -&gt; ST s [()]) -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681019769"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019769"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; ST s [()]
</span><a href="#local-6989586621681019802"><span class="hs-identifier hs-var">propFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019769"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Int] -&gt; Int
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681019982"><span class="hs-identifier hs-var">revPostOrder</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1336"></span><span>
</span><span id="line-1337"></span><span>    </span><span class="hs-comment">-- trace (&quot;Final freqs:&quot;) $ return ()</span><span>
</span><span id="line-1338"></span><span>    </span><span class="hs-comment">-- let freqString = pprFreqs freqs</span><span>
</span><span id="line-1339"></span><span>    </span><span class="hs-comment">-- trace (unlines freqString) $ return ()</span><span>
</span><span id="line-1340"></span><span>    </span><span class="hs-comment">-- trace (pprFre) $ return ()</span><span>
</span><span id="line-1341"></span><span>    </span><span id="local-6989586621681019767"><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019767"><span class="hs-identifier hs-var">graph'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double)) -&gt; ST s (IntMap (IntMap Double))
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s (IntMap (IntMap Double))
</span><a href="#local-6989586621681019867"><span class="hs-identifier hs-var">edgeProbs</span></a></span><span>
</span><span id="line-1342"></span><span>    </span><span id="local-6989586621681019766"><span class="annot"><span class="annottext">Array Int Double
</span><a href="#local-6989586621681019766"><span class="hs-identifier hs-var">freqs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STUArray s Int Double -&gt; ST s (Array Int Double)
forall i (a :: * -&gt; * -&gt; *) e (m :: * -&gt; *) (b :: * -&gt; * -&gt; *).
(Ix i, MArray a e m, IArray b e) =&gt;
a i e -&gt; m (b i e)
</span><a href="../../array/src/Data.Array.Base.html#unsafeFreeze"><span class="hs-identifier hs-var">unsafeFreeze</span></a></span><span>  </span><span class="annot"><span class="annottext">STUArray s Int Double
</span><a href="#local-6989586621681019875"><span class="hs-identifier hs-var">blockFreqs</span></a></span><span>
</span><span id="line-1343"></span><span>
</span><span id="line-1344"></span><span>    </span><span class="annot"><span class="annottext">(Array Int Double, IntMap (IntMap Double))
-&gt; ST s (Array Int Double, IntMap (IntMap Double))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array Int Double
</span><a href="#local-6989586621681019766"><span class="hs-identifier hs-var">freqs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019767"><span class="hs-identifier hs-var">graph'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1345"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1346"></span><span>    </span><span class="hs-comment">-- How can these lookups fail? Consider the CFG [A -&gt; B]</span><span>
</span><span id="line-1347"></span><span>    </span><span class="annot"><a href="#local-6989586621681019796"><span class="hs-identifier hs-type">predecessors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IS.IntSet</span></a></span><span>
</span><span id="line-1348"></span><span>    </span><span id="local-6989586621681019796"><span class="annot"><span class="annottext">predecessors :: Int -&gt; IntSet
</span><a href="#local-6989586621681019796"><span class="hs-identifier hs-var hs-var">predecessors</span></a></span></span><span> </span><span id="local-6989586621681019765"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019765"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IntSet -&gt; Maybe IntSet -&gt; IntSet
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">IntSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#empty"><span class="hs-identifier hs-var">IS.empty</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe IntSet -&gt; IntSet) -&gt; Maybe IntSet -&gt; IntSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap IntSet -&gt; Maybe IntSet
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019765"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019763"><span class="hs-identifier hs-var">revGraph</span></a></span><span>
</span><span id="line-1349"></span><span>    </span><span class="annot"><a href="#local-6989586621681019807"><span class="hs-identifier hs-type">successors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">]</span><span>
</span><span id="line-1350"></span><span>    </span><span id="local-6989586621681019807"><span class="annot"><span class="annottext">successors :: Int -&gt; [Int]
</span><a href="#local-6989586621681019807"><span class="hs-identifier hs-var hs-var">successors</span></a></span></span><span> </span><span id="local-6989586621681019762"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019762"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int] -&gt; Maybe [Int] -&gt; [Int]
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int -&gt; IntMap (IntMap Double) -&gt; [Int]
forall {a} {a}.
Outputable a =&gt;
String -&gt; a -&gt; IntMap (IntMap Double) -&gt; a
</span><a href="#local-6989586621681019761"><span class="hs-identifier hs-var">lookupError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;succ&quot;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019762"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(Maybe [Int] -&gt; [Int]) -&gt; Maybe [Int] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Double -&gt; [Int]
forall a. IntMap a -&gt; [Int]
</span><a href="../../containers/src/Data.IntMap.Internal.html#keys"><span class="hs-identifier hs-var">IM.keys</span></a></span><span> </span><span class="annot"><span class="annottext">(IntMap Double -&gt; [Int]) -&gt; Maybe (IntMap Double) -&gt; Maybe [Int]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap (IntMap Double) -&gt; Maybe (IntMap Double)
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IM.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019762"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1351"></span><span>    </span><span id="local-6989586621681019761"><span class="annot"><span class="annottext">lookupError :: String -&gt; a -&gt; IntMap (IntMap Double) -&gt; a
</span><a href="#local-6989586621681019761"><span class="hs-identifier hs-var hs-var">lookupError</span></a></span></span><span> </span><span id="local-6989586621681019749"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681019749"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621681019748"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681019748"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681019747"><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019747"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; a
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Lookup error &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681019749"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; a) -&gt; SDoc -&gt; a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1352"></span><span>                            </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;node&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681019748"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-1353"></span><span>                                </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;graph&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-1354"></span><span>                                </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Int, IntMap Double) -&gt; SDoc) -&gt; [(Int, IntMap Double)] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681019746"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019746"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681019745"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019745"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Int, IntMap Double) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019746"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019745"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IM.IntMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([(Int, IntMap Double)] -&gt; [SDoc])
-&gt; [(Int, IntMap Double)] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double) -&gt; [(Int, IntMap Double)]
forall a. IntMap a -&gt; [(Int, a)]
</span><a href="../../containers/src/Data.IntMap.Internal.html#toList"><span class="hs-identifier hs-var">IM.toList</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019747"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1355"></span><span>                            </span><span class="hs-special">)</span><span>
</span><span id="line-1356"></span><span>
</span><span id="line-1357"></span><span>    </span><span id="local-6989586621681019876"><span class="annot"><span class="annottext">nodeCount :: Int
</span><a href="#local-6989586621681019876"><span class="hs-identifier hs-var hs-var">nodeCount</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IntMap Double -&gt; Int)
-&gt; Int -&gt; IntMap (IntMap Double) -&gt; Int
forall a b. (a -&gt; b -&gt; a) -&gt; a -&gt; IntMap b -&gt; a
</span><a href="../../containers/src/Data.IntMap.Internal.html#foldl%27"><span class="hs-identifier hs-var">IM.foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019743"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019743"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span id="local-6989586621681019742"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019742"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int -&gt; Double -&gt; Int) -&gt; Int -&gt; IntMap Double -&gt; Int
forall a b. (a -&gt; Int -&gt; b -&gt; a) -&gt; a -&gt; IntMap b -&gt; a
</span><a href="../../containers/src/Data.IntMap.Internal.html#foldlWithKey%27"><span class="hs-identifier hs-var">IM.foldlWithKey'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Double -&gt; Int
</span><a href="#local-6989586621681019740"><span class="hs-identifier hs-var">countTargets</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019743"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019742"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IntMap (IntMap Double) -&gt; Int
forall a. IntMap a -&gt; Int
</span><a href="../../containers/src/Data.IntMap.Internal.html#size"><span class="hs-identifier hs-var">IM.size</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1358"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1359"></span><span>        </span><span id="local-6989586621681019740"><span class="annot"><span class="annottext">countTargets :: Int -&gt; Int -&gt; Double -&gt; Int
</span><a href="#local-6989586621681019740"><span class="hs-identifier hs-var hs-var">countTargets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019738"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019738"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span id="local-6989586621681019737"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019737"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="#local-6989586621681019736"><span class="hs-identifier hs-var">countNode</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019737"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019738"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1360"></span><span>        </span><span id="local-6989586621681019736"><span class="annot"><span class="annottext">countNode :: Int -&gt; Int
</span><a href="#local-6989586621681019736"><span class="hs-identifier hs-var hs-var">countNode</span></a></span></span><span> </span><span id="local-6989586621681019735"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019735"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap (IntMap Double) -&gt; Bool
forall a. Int -&gt; IntMap a -&gt; Bool
</span><a href="../../containers/src/Data.IntMap.Internal.html#member"><span class="hs-identifier hs-var">IM.member</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019735"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1361"></span><span>
</span><span id="line-1362"></span><span>    </span><span id="local-6989586621681019790"><span class="annot"><span class="annottext">isBackEdge :: Int -&gt; Int -&gt; Bool
</span><a href="#local-6989586621681019790"><span class="hs-identifier hs-var hs-var">isBackEdge</span></a></span></span><span> </span><span id="local-6989586621681019733"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019733"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681019732"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019732"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, Int) -&gt; Set (Int, Int) -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">S.member</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019733"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019732"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set (Int, Int)
</span><a href="#local-6989586621681019731"><span class="hs-identifier hs-var">backEdgeSet</span></a></span><span>
</span><span id="line-1363"></span><span>    </span><span id="local-6989586621681019731"><span class="annot"><span class="annottext">backEdgeSet :: Set (Int, Int)
</span><a href="#local-6989586621681019731"><span class="hs-identifier hs-var hs-var">backEdgeSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Int, Int)] -&gt; Set (Int, Int)
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">S.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">[(Int, Int)]
</span><a href="#local-6989586621681019984"><span class="hs-identifier hs-var">backEdges</span></a></span><span>
</span><span id="line-1364"></span><span>
</span><span id="line-1365"></span><span>    </span><span class="annot"><a href="#local-6989586621681019763"><span class="hs-identifier hs-type">revGraph</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IntMap</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span>
</span><span id="line-1366"></span><span>    </span><span id="local-6989586621681019763"><span class="annot"><span class="annottext">revGraph :: IntMap IntSet
</span><a href="#local-6989586621681019763"><span class="hs-identifier hs-var hs-var">revGraph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap IntSet -&gt; Int -&gt; IntMap Double -&gt; IntMap IntSet)
-&gt; IntMap IntSet -&gt; IntMap (IntMap Double) -&gt; IntMap IntSet
forall a b. (a -&gt; Int -&gt; b -&gt; a) -&gt; a -&gt; IntMap b -&gt; a
</span><a href="../../containers/src/Data.IntMap.Internal.html#foldlWithKey%27"><span class="hs-identifier hs-var">IM.foldlWithKey'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019730"><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019730"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681019729"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019729"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681019728"><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019728"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IntMap IntSet -&gt; Int -&gt; IntMap Double -&gt; IntMap IntSet
forall {b}. IntMap IntSet -&gt; Int -&gt; IntMap b -&gt; IntMap IntSet
</span><a href="#local-6989586621681019727"><span class="hs-identifier hs-var">addEdges</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019730"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019729"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Double
</span><a href="#local-6989586621681019728"><span class="hs-identifier hs-var">toMap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IM.empty</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (IntMap Double)
</span><a href="#local-6989586621681019985"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-1367"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-1368"></span><span>            </span><span id="local-6989586621681019727"><span class="annot"><span class="annottext">addEdges :: IntMap IntSet -&gt; Int -&gt; IntMap b -&gt; IntMap IntSet
</span><a href="#local-6989586621681019727"><span class="hs-identifier hs-var hs-var">addEdges</span></a></span></span><span> </span><span id="local-6989586621681019726"><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019726"><span class="hs-identifier hs-var">m0</span></a></span></span><span> </span><span id="local-6989586621681019725"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019725"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681019724"><span class="annot"><span class="annottext">IntMap b
</span><a href="#local-6989586621681019724"><span class="hs-identifier hs-var">toMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntMap IntSet -&gt; Int -&gt; b -&gt; IntMap IntSet)
-&gt; IntMap IntSet -&gt; IntMap b -&gt; IntMap IntSet
forall a b. (a -&gt; Int -&gt; b -&gt; a) -&gt; a -&gt; IntMap b -&gt; a
</span><a href="../../containers/src/Data.IntMap.Internal.html#foldlWithKey%27"><span class="hs-identifier hs-var">IM.foldlWithKey'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681019723"><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019723"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681019722"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019722"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IntMap IntSet -&gt; Int -&gt; Int -&gt; IntMap IntSet
</span><a href="#local-6989586621681019721"><span class="hs-identifier hs-var">addEdge</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019723"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019725"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019722"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019726"><span class="hs-identifier hs-var">m0</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap b
</span><a href="#local-6989586621681019724"><span class="hs-identifier hs-var">toMap</span></a></span><span>
</span><span id="line-1369"></span><span>            </span><span id="local-6989586621681019721"><span class="annot"><span class="annottext">addEdge :: IntMap IntSet -&gt; Int -&gt; Int -&gt; IntMap IntSet
</span><a href="#local-6989586621681019721"><span class="hs-identifier hs-var hs-var">addEdge</span></a></span></span><span> </span><span id="local-6989586621681019720"><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019720"><span class="hs-identifier hs-var">m0</span></a></span></span><span> </span><span id="local-6989586621681019719"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019719"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681019718"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019718"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IntSet -&gt; IntSet -&gt; IntSet)
-&gt; Int -&gt; IntSet -&gt; IntMap IntSet -&gt; IntMap IntSet
forall a. (a -&gt; a -&gt; a) -&gt; Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Strict.Internal.html#insertWith"><span class="hs-identifier hs-var">IM.insertWith</span></a></span><span> </span><span class="annot"><span class="annottext">IntSet -&gt; IntSet -&gt; IntSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#union"><span class="hs-identifier hs-var">IS.union</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019718"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; IntSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#singleton"><span class="hs-identifier hs-var">IS.singleton</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681019719"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap IntSet
</span><a href="#local-6989586621681019720"><span class="hs-identifier hs-var">m0</span></a></span><span>
</span><span id="line-1370"></span></pre></body></html>